Re: Do not understand the - macro here

2014-05-03 Thread Michael Wood
That whole form is not something you would be likely to write. I think the exercise is just trying to demonstrate that the version with the - is equivalent to the version without the arrow and perhaps also that (= a b c) can be used instead of (and (= a b) (= b c)). -- Michael Wood On 01 May

Re: Do not understand the - macro here

2014-05-01 Thread Roelof Wobben
Is this a nice explanation about macros : http://bryangilbert.com/code/2013/07/30/anatomy-of-a-clojure-macro/ or is there a better one for a beginner. Roelof -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: Do not understand the - macro here

2014-05-01 Thread Erlis Vidal
I think the confusion is because they used multiple values when comparing the equality (= (__ (sort (rest (reverse [2 5 4 1 3 6] (- [2 5 4 1 3 6] (reverse) (rest) (sort) (__)) 5) This can be seen as : (def A (__ (sort (rest (reverse [2 5 4 1 3 6]) (def B (- [2 5 4 1 3 6] (reverse)

Re: Do not understand the - macro here

2014-05-01 Thread Roelof Wobben
Op donderdag 1 mei 2014 15:20:38 UTC+2 schreef Erlis Vidal: I think the confusion is because they used multiple values when comparing the equality (= (__ (sort (rest (reverse [2 5 4 1 3 6] (- [2 5 4 1 3 6] (reverse) (rest) (sort) (__)) 5) This can be seen as : (def A (__

Re: Do not understand the - macro here

2014-05-01 Thread Maik Schünemann
On Thu, May 1, 2014 at 3:51 PM, Roelof Wobben rwob...@hotmail.com wrote: Op donderdag 1 mei 2014 15:20:38 UTC+2 schreef Erlis Vidal: I think the confusion is because they used multiple values when comparing the equality (= (__ (sort (rest (reverse [2 5 4 1 3 6] (- [2 5 4 1 3 6]

Re: Do not understand the - macro here

2014-05-01 Thread Maik Schünemann
The task is to replace __ with the function that makes this true in this case makes [1 2 3 4 5] to 5 On Thu, May 1, 2014 at 4:23 PM, Maik Schünemann maikschuenem...@gmail.comwrote: On Thu, May 1, 2014 at 3:51 PM, Roelof Wobben rwob...@hotmail.com wrote: Op donderdag 1 mei 2014 15:20:38

Re: Do not understand the - macro here

2014-05-01 Thread Erlis Vidal
Look that (def A ...) won't compile as given, so you cannot say A is [1 2 3 4 5], A is something else once you make it compile filling the blank space with the missing function. On Thu, May 1, 2014 at 10:24 AM, Maik Schünemann maikschuenem...@gmail.comwrote: The task is to replace __ with the

Re: Do not understand the - macro here

2014-05-01 Thread Roelof Wobben
oke, I misunderstood everyone. The right answer is last. (def A (__ (sort (rest (reverse [2 5 4 1 3 6]) which would be : (def A (last (sort (rest (reverse [2 5 4 1 3 6]) which resolves to 5 (def B (- [2 5 4 1 3 6] (reverse) (rest) (sort) (__))) Which would be : (def B (- [2 5 4 1

Do not understand the - macro here

2014-04-30 Thread Roelof Wobben
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

Re: Do not understand the - macro here

2014-04-30 Thread Walter van der Laan
You have to replace the underscore with a function. The value of (= (_ [1 2 3 4 5]) 5) must be true. So the value of (_ [1 2 3 4 5]) must be 5. So the function you are looking for will have to return the last element of the array. On Wednesday, April 30, 2014 5:28:26 PM UTC+2, Roelof Wobben

Re: Do not understand the - macro here

2014-04-30 Thread Dmitry Lipovoi
It looks like a quiz. Which function should stand in place of underscores to give 5 in result? On Wed, Apr 30, 2014 at 7:28 PM, 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)

Re: Do not understand the - macro here

2014-04-30 Thread James Reeves
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]])

Re: Do not understand the - macro here

2014-04-30 Thread Roelof Wobben
Op woensdag 30 april 2014 18:46:36 UTC+2 schreef James Reeves: 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

Re: Do not understand the - macro here

2014-04-30 Thread Roelof Wobben
Op woensdag 30 april 2014 19:12:24 UTC+2 schreef James Reeves: The 5 is just the last part of the equality statement. This might be easier to see by adding in a let: (let [x (__ (sort (rest (reverse [2 5 4 1 3 6] y (- [2 5 4 1 3 6] (reverse) (rest) (sort) (__))] (= x y 5))

Re: Do not understand the - macro here

2014-04-30 Thread James Reeves
The 5 is just the last part of the equality statement. This might be easier to see by adding in a let: (let [x (__ (sort (rest (reverse [2 5 4 1 3 6] y (- [2 5 4 1 3 6] (reverse) (rest) (sort) (__))] (= x y 5)) - James On 30 April 2014 18:09, Roelof Wobben rwob...@hotmail.com

Re: Do not understand the - macro here

2014-04-30 Thread James Reeves
The __ needs to be replaced with a function. So essentially it boils down to: (= (__ [1 2 3 4 5]) 5) What function when called with [1 2 3 4 5] returns 5? - James On 30 April 2014 18:18, Roelof Wobben rwob...@hotmail.com wrote: Op woensdag 30 april 2014 19:12:24 UTC+2 schreef James

Re: Do not understand the - macro here

2014-04-30 Thread Roelof Wobben
Op woensdag 30 april 2014 19:46:41 UTC+2 schreef James Reeves: The __ needs to be replaced with a function. So essentially it boils down to: (= (__ [1 2 3 4 5]) 5) What function when called with [1 2 3 4 5] returns 5? - James Thats a easy one . That is last. But what I try to