On Tue, May 24, 2011 at 4:10 PM, MarisO <[email protected]> wrote:
> Is it possible to use list comprehension to generate a set ?
> For example in scala I can do:
>
> for (i <- (2 to 8).toSet[Int]) yield p(i)
>
> In clojure this
>
> (for [ x (set (range 4))] (* 4 x))
>
>  generates a list.

(set (for [x (range 4)] (* 4 x)))
;=> #{0 4 8 12}

Does that help?

Regards,
BG

-- 
Baishampayan Ghose
b.ghose at gmail.com

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
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

Reply via email to