> I sort of remember Rich Hickey say this, but I am not sure :).
I was a bit mistaken.
In this video (
http://blip.tv/clojure/clojure-data-structures-part-2-714064 ) , around
42nd minute, he says that assoc is "the normal way" and is "more
convenient" because you can assoc multiple keys and val
: (if (seq my-map) this that).
On Thursday, August 30, 2012 12:46:05 AM UTC+2, Brian Marick wrote:
>
>
> On Aug 29, 2012, at 2:08 PM, dmirylenka wrote:
>
> > I would say, they treat nil as an empty sequence, which makes nil,
> effectively, a unit:
> >
> > (asso
I sort of remember Rich Hickey say this, but I am not sure :).
As far as I see it, it is generally better to use more specific functions,
as they make the assumptions about the types of the arguments more
explicit. Sometimes they are also more efficient (but probably not in this
case).
So, for
On Aug 29, 2012, at 2:08 PM, 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}
It's not a unit if you're using `if-let` and expec
Hi,
Am 29.08.2012 um 23:38 schrieb dmirylenka:
> Although, code working with maps shouldn't use conj anyway.
Why?
Kind regards
Meikel
signature.asc
Description: Message signed with OpenPGP using GPGMail
lenka 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:
>&
On Aug 29, 2012, at 12:18 PM, Brian Marick wrote:
> Why does `(merge)` return nil? I would have expected it to return the unit
> ({})
I agree with your intuition -- I expected an empty map. However, the doc says
"Returns a map that consists of the rest of the maps conj-ed onto the first"
wh
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/
On Wed, Aug 29, 2012 at 9:41 AM, Joop Kiefte wrote:
> An empty sequence is equal to nil.
How so?
user> (some #(= % nil) ['() [] {}])
nil
--
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks,
which may be sweet, aromatic, fermented or spirit-based. ... Family
and s
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 wrote:
> An empty sequence is equal to nil.
>
> 2012/8/29 Ambrose Bonnaire-Sergeant :
> > My guess is t
On Thu, Aug 30, 2012 at 12:41 AM, Joop Kiefte wrote:
> An empty sequence is equal to nil.
>
What do you mean?
=> (seq? ())
true
=> (= nil ())
false
>
> 2012/8/29 Ambrose Bonnaire-Sergeant :
> > My guess is that `merge` has an invariant "if all args are nil, return
> nil",
> > making calls to
An empty sequence is equal to nil.
2012/8/29 Ambrose Bonnaire-Sergeant :
> 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,
> Ambr
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 wrote:
> Why does `(merge)` return ni
Don't know why nil is returned instead of {}, but
> (+) => 0
> (*) => 1
following that line of reasoning:
> (merge nil {:a 1})
{:a 1}
> (merge {} {:a 1})
{:a 1}
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To
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 subsc
15 matches
Mail list logo