On Mar 2, 2009, at 3:39 AM, Meikel Brandmeyer wrote:
>
>> Does Clojure have an analog of Lisp's MEMBER function?
>> (member 'a '(c a f e b a b e)) => (A F E B A B E)
>
> I don't know the member function of CL, but I interpret
> your example, that it cuts away the head of the list until
> the first occurence of the given thing.
>
MEMBER is a fancy predicate that tests whether or not an item is an
element of a given list. I say fancy because rather than simply
returning true when the item is present it returns the tail of the
list starting with the item. It returns nil otherwise. I don't care
about this fancy value. I just want to know whether or not the item
is in the list without too much verbosity.
I think (some #{<ITEM>} <LIST>) is probably the way to do it.
> You can do that in Clojure with drop-while:
>
> (drop-while #(not= % :a) (list :c :a :f :e :b :a :b :e))
> => (:a :f :e :b :a :b :e)
>
Thanks for your example anyway.
Mahalo nui loa (vielen dank),
David Sletten
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---