Jay Fields <[email protected]> writes:
> right, I know it's possible to do what you guys are describing. What I
> meant to ask is, should :or be allowed in destructuring vectors? I
> can't see any reason for it not to be allowed.
Hm, yes, I could think of these semantics, i.e., fill missing indices
with the values given by the :or vector.
(map #(let [[x y & more :or [1 2 3 4]] %1]
(apply vector x y more))
[[2 3 4 5]
[nil nil nil nil]
[2 3 4]
[nil 3]
[nil 2 nil]
[5]
[]]
;=> [[2 3 4 5]
[nil nil nil nil]
[2 3 4]
[1 3 3 4]
[1 2 nil]
[5 2 3 4]
[1 2 3 4]]
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