A (very) few UI improvements
[eigenmath-fx.git] / find.cpp
blob5f14531c67821eeb176a1f7afa6c2f9d5e73eb88
1 // returns 1 if expr p contains expr q, otherweise returns 0
3 #include "stdafx.h"
4 #include "defs.h"
6 int
7 find(U *p, U *q)
9 int i;
11 if (equal(p, q))
12 return 1;
14 if (istensor(p)) {
15 for (i = 0; i < p->u.tensor->nelem; i++)
16 if (find(p->u.tensor->elem[i], q))
17 return 1;
18 return 0;
21 while (iscons(p)) {
22 if (find(car(p), q))
23 return 1;
24 p = cdr(p);
27 return 0;