Jay Fields <[email protected]> writes:
Hi Jay,
> Is there any reason that (let [[x y :or {x 1 y 2}] nil] [x y]) can't
> work?
:or is only supported for map destructuring but you use sequence
destructuring.
user> (map #(let [{x :x, y :y :or {x 1, y 2}} %1]
[x y])
[{} {:x 17, :y 3} {:y 1}])
([1 2] [17 3] [1 1])
Well, you can use map destructuring also for vectors, because those are
associatives of their indexes. However, then the :or doesn't seem to
work as expected. Not sure if I'm doing something wrong or if it's
really not supported. In the latter case, maybe an exception was
justified.
user> (map #(let [{x 0 y 1 :or {0 -1, 1 -2}} %1]
[x y])
[[] [10] [10 11]])
([nil nil] [10 nil] [10 11])
I had expected it to return ([-1 -2] [10 -2] [10 11]).
Bye,
Tassilo
--
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