[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Nov 15 15:52:54 1992 
Subject:Re: A little Pop history 
From:Jonathan Laventhol 
Volume-ID:921116.01 

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.