Re: destructuring with :or

2012-06-12 Thread Tassilo Horn
Jay Fields 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

Re: destructuring with :or

2012-06-12 Thread Tassilo Horn
Sean Corfield writes: >> 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]). > > It needs to be this: > > user=> (map #(let [{x 0 y 1 :or {x -1 y -2}} %]

Re: destructuring with :or

2012-06-12 Thread Jay Fields
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. On Jun 12, 2012, at 7:10 PM, Sean Corfield wrote: > On Tue, Jun 12, 2012 at 12:28 PM, Tassilo Horn wrote: >>

Re: destructuring with :or

2012-06-12 Thread Sean Corfield
On Tue, Jun 12, 2012 at 12:28 PM, Tassilo Horn wrote: > 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]). It needs to be this: user=> (map #(let [{x 0 y 1

Re: destructuring with :or

2012-06-12 Thread Tassilo Horn
Jay Fields 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}])