> 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 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))
: (mmbr 'D '(A B C))
> I also saw find...but wasn't sure exactly how I'd apply that.
: (find '((X) (== X 'B)) '(A B C))
> BTW which is the most efficient loop in Picolisp from an execution
I would say 'while' and 'until', or 'do' for counted loops.
You can experiment with 'bench' to compare the relative speeds.