You can use destructuring
user=> (let [[a b] [(+ 1 2) (+ 2 3)]]
         [a b])
[3 5]


Christopher Howard writes:

> In Clojure, what is the easiest (cleanest) way to return "multiple"
> values from a function, in order to work with them immediately
> afterwards? In Haskell you can return a tuple, and pattern match the
> components into variables.
>
> Prelude> let (a, b) = (1 + 4, 2 - 1)
> Prelude> a
> 5
> Prelude> b
> 1
>
> IIRC, Python has something similar.
>
> I know how to return a list or a vector, of course, but I'm imagining
> having to put in a bunch of cludgy code to extract the components into
> variables, which is not appealing.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to