Re: figuring out sets

2010-11-02 Thread Alan
Except when they are small enough to conveniently be array-maps: user=> (class (into {} (zipmap (range) (range 8 clojure.lang.PersistentArrayMap user=> (class (into {} (zipmap (range) (range 9 clojure.lang.PersistentHashMap But those behave just like hash-maps, so you can ignore the diffe

Re: figuring out sets

2010-11-02 Thread tonyl
Wow, this brings more light to the subject. Thank you guys for your explanations and practical uses. On Nov 2, 1:31 am, Rasmus Svensson wrote: > 2010/11/1 tonyl : > > > I was wondering since it uses the dispatch macro and AFAIK > > there is no api fn to create them like hash-maps to create maps,

Re: figuring out sets

2010-11-01 Thread Rasmus Svensson
2010/11/1 tonyl : > I was wondering since it uses the dispatch macro and AFAIK > there is no api fn to create them like hash-maps to create maps, > vector/vec for vectors, or list for lists. There are parallels to 'hash-map' and 'sorted-map' in the api: user=> (hash-set :a :b :c) #{:a :c :b} user

Re: figuring out sets

2010-10-31 Thread Shantanu Kumar
Or just this: user=> (set [1 2 3 4 5 8 8 9 6 6 4]) #{1 2 3 4 5 6 8 9} On Nov 1, 8:11 am, Shantanu Kumar wrote: > You can write something like this: > > user=> (into #{} [1 2 3 4 5 8 8 9 6 6 4]) > #{1 2 3 4 5 6 8 9} > > Cheers, > Shantanu > > On Nov 1, 7:55 am, tonyl wrote: > > > > > > > > > I g

Re: figuring out sets

2010-10-31 Thread David Sletten
>From a mathematical perspective the essential aspect of a set is its >extension, namely what elements are contained in the set. This leads >immediately to the property of uniqueness you mentioned. But the fundamental >operation is 'contains?'. In other words, does the set contain some object or

Re: figuring out sets

2010-10-31 Thread Shantanu Kumar
You can write something like this: user=> (into #{} [1 2 3 4 5 8 8 9 6 6 4]) #{1 2 3 4 5 6 8 9} Cheers, Shantanu On Nov 1, 7:55 am, tonyl wrote: > I guess I should've look harder (and ask more in the irc ;) it is a > data structure and has a set fn too. #{} is just a reader macro for > syntacti

Re: figuring out sets

2010-10-31 Thread tonyl
I guess I should've look harder (and ask more in the irc ;) it is a data structure and has a set fn too. #{} is just a reader macro for syntactic sugar. And the difference of usage between sets and vectors are they sets can't have duplicates. This is great, clojure group with irc chat, good learnin

figuring out sets

2010-10-31 Thread tonyl
I've been wondering if sets are actually a defined data structure like vectors and maps or are they a result of an expansion of the dispatch macro? I was wondering since it uses the dispatch macro and AFAIK there is no api fn to create them like hash-maps to create maps, vector/vec for vectors, or