Hi --
Yep, of course, Brian was right and saw my bug. Well, here's
the fixings.
define recursivemember(item, list);
var item, list, element;
if list = [] then
return(false)
endif;
for el in list do
if el = item then
return(true)
elseif islist(el) and recursivemember(item, el) then
return(true);
endif
endfor;
return(false);
enddefine;
This illustrates another facet of the language: that boolean
expression evaluation is defined to be ordered (left to right), as is
argument evaluation.
Sorry/thanks.
J.
bh@anarres.CS.Berkeley.EDU (Brian Harvey) writes:
>jcl@deshaw.com (Jonathan Laventhol) writes:
[...]
>| for el in list do
>| if el = item then
>| return(true)
>| elseif islist(el) then
>| return(recursivemember(item, el));
>| endif
>| endfor;
[...]
>Can this be right? It looks to me as if it'll say that X isn't
>a recursivemember of [[A B C] [X Y Z]] because it isn't in the
>first sublist.
|