eigenmath/find.cpp

29 lines
383 B
C++
Raw Permalink Normal View History

2004-05-14 17:22:08 +02:00
// returns 1 if expr p contains expr q, otherweise returns 0
#include "stdafx.h"
#include "defs.h"
int
find(U *p, U *q)
{
int i;
if (equal(p, q))
return 1;
2005-08-06 22:57:37 +02:00
if (istensor(p)) {
2004-05-14 17:22:08 +02:00
for (i = 0; i < p->u.tensor->nelem; i++)
if (find(p->u.tensor->elem[i], q))
return 1;
return 0;
}
while (iscons(p)) {
if (find(car(p), q))
return 1;
p = cdr(p);
}
return 0;
}