Right. It's similar to writing:

(def x 5)

(= #{x} #{5})

You'd expect that to be true, right?


When Clojure comes across an unquoted symbol (like x or octavia), it tries
to evaluate it, replacing it with the value it represents.

In a similar way, unquoted lists (anything in parentheses) are also
evaluated as functions, macros or special forms.

So: (= #{x} #{5})

Becomes: (= #{5} #{5})

Becomes: true

- James

On 27 October 2014 21:16, Roelof Wobben <rwob...@hotmail.com> wrote:

> Np, So if I understand it right. I see the first one in repl.
> Because midje has #{octavia} and in another function is stated :
>
> (def octavia {:name "Octavia E. Butler"
>               :birth-year 1947
>               :death-year 2006})
>
>
> clojure makes from the first  {octavia} the second {:name "Octavia E.
> Butler" :birth-year 1947 :death-year 2006})
> so that is why there are both the same.
>
> Roelof
>
>
>
> Op maandag 27 oktober 2014 22:09:04 UTC+1 schreef James Reeves:
>
>> Sorry, I misplaced a couple of brackets:
>>
>> (= {:title "Wild Seed", :authors #{{:name "Octavia E. Butler",
>> :birth-year 1947, :death-year 2006}}}
>>    {:title "Wild Seed", :authors #{octavia}})
>>
>> That should work.
>>
>> - James
>>
>> On 27 October 2014 20:20, Roelof Wobben <rwo...@hotmail.com> wrote:
>>
>>> nope, there is somewhere a error in the example.
>>>
>>> When I copie it as you made it then I see this error message :
>>> RuntimeException Unmatched delimiter: }  clojure.lang.
>>> Util.runtimeException (Util.java:219)
>>> when I add a extra )  I see this message :  RuntimeException Map literal
>>> must contain an even number of forms  clojure.lang.Util.
>>> runtimeException (Util.java:219)
>>>
>>>
>>>
>>> Roelof
>>>
>>>
>>> Op maandag 27 oktober 2014 20:46:49 UTC+1 schreef James Reeves:
>>>
>>>> On 27 October 2014 19:37, Roelof Wobben <rwo...@hotmail.com> wrote:
>>>>
>>>>> of course I can.
>>>>>
>>>>> If I look at answers other people gives then this is the solution :
>>>>>
>>>>> (defn old-book->new-book [book]
>>>>>  (assoc book :authors (set (book :authors)))
>>>>>  )
>>>>>
>>>>> and then according to the explanation I would see this output ;
>>>>>
>>>>> (old-book->new-book {:title "Wild Seed", :authors [octavia]});=> {:title 
>>>>> "Wild Seed", :authors #{octavia}}
>>>>>
>>>>> but on 1.6.0 and on 1.5.1 I see another output as discussed here.
>>>>>
>>>>>
>>>> I don't think you're understanding that:
>>>>
>>>> {:title "Wild Seed", :authors #{{:name "Octavia E. Butler", :birth-year 
>>>> 1947, :death-year 2006}}}
>>>>
>>>> Evaluates to the same thing as:
>>>>
>>>> {:title "Wild Seed", :authors #{octavia}}
>>>>
>>>> The difference is that in the first value, "octavia" has been replaced
>>>> with its value.
>>>>
>>>> You can confirm the two data structures are the same by checking their
>>>> equality:
>>>>
>>>> (= {:title "Wild Seed", :authors #{{:name "Octavia E. Butler", :birth-year 
>>>> 1947, :death-year 2006}}
>>>>    {:title "Wild Seed", :authors #{octavia}}}
>>>>
>>>> This should return true.
>>>>
>>>> - James
>>>>
>>>
>>

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