These two forms are equivalent:

    (__ (sort (rest (reverse [2 5 4 1 3 6]))))

    (-> [2 5 4 1 3 6] (reverse) (rest) (sort) (__))

The -> macro turns the second form into the first. You can see this by
running macroexpand-all:

    (require '[clojure.walk :refer [macroexpand-all]])

    (macroexpand-all '(-> [2 5 4 1 3 6] (reverse) (rest) (sort) (__)))

This should produce:

   (__ (sort (rest (reverse [2 5 4 1 3 6]))))

- James


On 30 April 2014 16:28, Roelof Wobben <rwob...@hotmail.com> wrote:

> On 4 clojure there it this exercise:
>
> (= (__ (sort (rest (reverse [2 5 4 1 3 6]))))
>    (-> [2 5 4 1 3 6] (reverse) (rest) (sort) (__))
>    5)
>
> if I understand it right this is happen
>
> reverse[ 2 5 4 1 3 6] gives [ 6 3 1 4 5 2 ]
> Then rest [ 6 3 1 4 5 2] gives [ 3 1 4 5 2]
> Sort this and you get [ 1 2 3 4 5]
>
> This part : [2 5 4 1 3 6] (reverse) (rest) (sort) gives the same output: [
> 1 2 3 4 5]
>
> what does the (__)) 5) does exactly. When I change the 5 to another number
> the outcome is not changed.
> And where does clojure put the first [ 1 2 3 4 5 ] in the second form ?
>
> Roelof
>
>
>
>  --
> 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.
>

-- 
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