Re: Set as function

2010-04-06 Thread Sophie
On Apr 6, 12:16 am, Alex Osborne wrote: > Calling the set as if it is a fn is a short-hand for "get", that is > retrieving an element from the set. Why would you want to do this, when > to look it up you need to know what element is?  Sets are based on > value-equality not reference-equality.  T

Re: Set as function

2010-04-06 Thread Alex Osborne
B Smith-Mannschott writes: >> Calling the set as if it is a fn is a short-hand for "get", that is >> retrieving an element from the set. Why would you want to do this, when >> to look it up you need to know what element is? > > Since you asked: canonicalization. I've wanted this on occasion (in >

Re: Set as function

2010-04-05 Thread B Smith-Mannschott
On Tue, Apr 6, 2010 at 07:16, Alex Osborne wrote: > Mark Engelberg writes: > >> filter works just as well with a function that returns true and false, >> so that's not a particularly good example. > > Calling the set as if it is a fn is a short-hand for "get", that is > retrieving an element from

Re: Set as function

2010-04-05 Thread Alex Osborne
Mark Engelberg writes: > filter works just as well with a function that returns true and false, > so that's not a particularly good example. Calling the set as if it is a fn is a short-hand for "get", that is retrieving an element from the set. Why would you want to do this, when to look it up y

Re: Set as function

2010-04-05 Thread Chouser
On Apr 6, 2010, at 12:20 AM, Mark Engelberg wrote: On Mon, Apr 5, 2010 at 8:56 PM, Richard Newman wrote: Why this behavior? It's useful: e.g., you can use a set as a filter. user=> (filter #{2 3 4 5} (range 1 10)) (2 3 4 5) filter works just as well with a function that returns true

Re: Set as function

2010-04-05 Thread Richard Newman
filter works just as well with a function that returns true and false, so that's not a particularly good example. Heh, that's true. Should have re-read :) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@

Re: Set as function

2010-04-05 Thread Mark Engelberg
On Mon, Apr 5, 2010 at 8:56 PM, Richard Newman wrote: > Why this behavior? >> > > It's useful: e.g., you can use a set as a filter. > > user=> (filter #{2 3 4 5} (range 1 10)) > (2 3 4 5) > > filter works just as well with a function that returns true and false, so that's not a particularly good

Re: Set as function

2010-04-05 Thread Richard Newman
Why this behavior? It's useful: e.g., you can use a set as a filter. user=> (filter #{2 3 4 5} (range 1 10)) (2 3 4 5) If you want your alternative, use contains?: user=> (contains? #{true false} false) true -- You received this message because you are subscribed to the Google Groups "Clojur

Set as function

2010-04-05 Thread Sophie
Why this behavior? user=> (#{5 nil} 5) 5 user=> (#{5 nil} 4) nil user=> (#{5 nil} nil) nil rather than the seemingly more informative: user=> (#{5 nil} 5) true user=> (#{5 nil} 4) false user=> (#{5 nil} nil) true user=> (#{5 false} true) false user=> (#{5 false} false) true i.e. set as character