repo.or.cz
/
eigenmath-fx.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
A (very) few UI improvements
[eigenmath-fx.git]
/
find.cpp
blob
5f14531c67821eeb176a1f7afa6c2f9d5e73eb88
1
// returns 1 if expr p contains expr q, otherweise returns 0
2
3
#include
"stdafx.h"
4
#include
"defs.h"
5
6
int
7
find
(
U
*
p
,
U
*
q
)
8
{
9
int
i
;
10
11
if
(
equal
(
p
,
q
))
12
return
1
;
13
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
;
19
}
20
21
while
(
iscons
(
p
)) {
22
if
(
find
(
car
(
p
),
q
))
23
return
1
;
24
p
=
cdr
(
p
);
25
}
26
27
return
0
;
28
}