If I isolate the following line... I get T as undefined
: (T (== 1 1) T)
!? (T (== 1 1) T)
T -- Undefined
Whereas...inside the function
(de mmbr (Trgt L)
(for Ele L
#(T (== Ele Trgt) T)
(T (== 1 1) T)
: (mmbr 'B '(A B C))
: (mmbr 'D '(A B C))
it works fine.
I'm not sure how the first T acts as a function on the next 2 arguments
(== 1 1) and T but see that there's an implied AND between the two.
i.e. I'm assuming this is a...
"A list is evaluated as a function call, with the CAR as the function
and the CDR the arguments to that function. These arguments are in turn
evaluated according to these three rules."
Any help to understand what's happening would be much appreciated
On 23 November 2016 at 21:24, dean <deangwillia...@gmail.com> wrote:
> Thank you very much for this.
> Best Regards
> On 23 November 2016 at 21:00, Alexander Burger <a...@software-lab.de>
>> 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
>> > 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:email@example.com?subject=Unsubscribe