Hm.. There seem to be cases when nil is not equivalent to {} when working
with maps:
(conj {} [:a :b]); => {:a :b}
(conj nil [:a :b]); => ([:a :b])
Although, code working with maps shouldn't use conj anyway.
Any other examples?
On Wednesday, August 29, 2012 9:08:07 PM UTC+2, dmirylenka wrote:
>
> I would say, they treat nil as an empty sequence, which makes nil,
> effectively, a unit:
>
> (assoc nil :a :b) ; => {:a :b}
> (merge nil {:a :b}) ; => {:a :b}
>
> etc.
>
> On Wednesday, August 29, 2012 7:36:26 PM UTC+2, Moritz Ulrich wrote:
>>
>> This isn't true in Clojure: http://clojure.org/lisps
>>
>> However, most functions treat an empty seq as nil because they call `seq'
>> on their arguments.
>>
>> On Wed, Aug 29, 2012 at 6:41 PM, Joop Kiefte <[email protected]> wrote:
>>
>>> An empty sequence is equal to nil.
>>>
>>> 2012/8/29 Ambrose Bonnaire-Sergeant <[email protected]>:
>>> > My guess is that `merge` has an invariant "if all args are nil, return
>>> nil",
>>> > making calls to `seq` "contagious" from args to return value.
>>> >
>>> > => (merge (seq {}) (seq {}))
>>> > nil
>>> >
>>> > Just a guess though.
>>> >
>>> > Thanks,
>>> > Ambrose
>>> >
>>> > On Thu, Aug 30, 2012 at 12:18 AM, Brian Marick <[email protected]>
>>> wrote:
>>> >>
>>> >> Why does `(merge)` return nil? I would have expected it to return the
>>> unit
>>> >> ({}) by analogy with things like this:
>>> >>
>>> >> (+) => 0
>>> >> (*) => 1
>>> >>
>>> >> -----
>>> >> Brian Marick, Artisanal Labrador
>>> >> Contract programming in Ruby and Clojure
>>> >> Occasional consulting on Agile
>>> >>
>>> >>
>>> >> --
>>> >> 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
>>> >
>>> >
>>> > --
>>> > 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
>>>
>>> --
>>> 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
>>>
>>
>>
--
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