Hi Dean, > I'm just wondering what my options are re doing this.... > > (de mmbr (Trgt L) > (for Ele L > (if (== Ele Trgt) (println "found so exit with true") > (println "try next") > ) > ) > (prinl "list exhausted so return false") > ) > > (mmbr 'B '(A B C)) > > I only know how to iterate over lists using for but don't know how to exit > for.
For simply finding an element in a list, you can use 'member' or 'memq' (memq 'B '(A B C)) It returns the restlist, or NIL if not found. To implement it yourself, you could do (de mmbr (Trgt L) (for Ele L (T (== Ele Trgt) T) ) ) : (mmbr 'B '(A B C)) -> T : (mmbr 'D '(A B C)) -> NIL > I also saw find...but wasn't sure exactly how I'd apply that. : (find '((X) (== X 'B)) '(A B C)) -> B > BTW which is the most efficient loop in Picolisp from an execution > perspective? I would say 'while' and 'until', or 'do' for counted loops. You can experiment with 'bench' to compare the relative speeds. ♪♫ Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe