On Apr 16, 2009, at 1:57 AM, bOR_ wrote:
> > (fn [n] :new) or (constantly :new) was what I was looking for. > > Just found out the two are not exactly the same. Hmm. I guess I should > have expected this from the docstring. Anyway, thanks all! > > Clojure=> (map (constantly (ref nil)) (range 10)) > 50 (#<Ref clojure.lang....@1417690> #<Ref clojure.lang....@1417690> > #<Ref clojure.lang....@1417690> #<Ref clojure.lang....@1417690> #<Ref > clojure.lang....@1 417690> #<Ref clojure.lang....@1417690> #<Ref > clojure.lang....@1417690> #<Ref clojure.lang....@1417690> #<Ref > clojure.lang....@1417690> #<Ref clojure.lan g....@1417690>) > > 51 Clojure=> (map (fn [n] (ref nil)) (range 10)) > 52 (#<Ref clojure.lang....@1e32382> #<Ref clojure.lang....@1304043> > #<Ref clojure.lang....@cb07ef> #<Ref clojure.lang....@176086d> #<Ref > clojure.lang....@23 4265> #<Ref clojure.lang....@dc1f04> #<Ref > clojure.lang....@1784427> #<Ref clojure.lang....@c272bc> #<Ref > clojure.lang....@1fac852> #<Ref clojure.lang.Re f...@1758cd1>) > > In that case, here's something that reads more clearly to me: (take 10 (repeatedly #(ref nil))) => (#<r...@66036e: nil> #<r...@6b6b13: nil> #<r...@42c747: nil> #<r...@2943ff: nil> #<r...@2f4fc5: nil> #<r...@1e4683: nil> #<r...@a761ce: nil> #<r...@622e6: nil> #<r...@2689a7: nil> #<r...@173b39: nil>) Also, in your second example above, I think it's more idiomatic to write (fn [_] (ref nil)) to demonstrate that you're ignoring the argument. Aloha, David Sletten --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---