Re: Hash-map destructuring

2010-06-25 Thread Chas Emerick
On Jun 16, 2010, at 9:21 PM, Michael Gardner wrote: On Jun 16, 2010, at 7:07 PM, ataggart wrote: There's a disconnect between the function definition and the datastructures used by the caller. Either fix the data structure: (def args [:bar 2 :baz [:quux]]) then use apply Or change the

Re: Hash-map destructuring

2010-06-25 Thread Brian Carper
On Jun 25, 2:57 am, Chas Emerick cemer...@snowtide.com wrote: This is fairly simple: user= (defn foo [ {:as args}] [args]) #'user/foo user= (def m {:a 5 :b 6}) #'user/m user= (apply foo (- m seq flatten)) [{:a 5, :b 6}] I'm not sure if it could be made easier, short of changing apply  

Re: Hash-map destructuring

2010-06-25 Thread David Nolen
On Wed, Jun 16, 2010 at 7:00 PM, Brian Carper briancar...@gmail.com wrote: Given: (defn foo [x {:as args}] [x args]) (foo 1 :bar 2 :baz [:quux]) = [1 {:bar 2, :baz [:quux]}] If I have those rest-arguments already in a map, what's the most elegant way to call foo with them? (def args

Re: Hash-map destructuring

2010-06-16 Thread ataggart
There's a disconnect between the function definition and the datastructures used by the caller. Either fix the data structure: (def args [:bar 2 :baz [:quux]]) then use apply Or change the function definition to take a map: (defn foo [x {:keys [bar baz]}] ...) On Jun 16, 4:00 pm, Brian

Re: Hash-map destructuring

2010-06-16 Thread Michael Gardner
On Jun 16, 2010, at 7:07 PM, ataggart wrote: There's a disconnect between the function definition and the datastructures used by the caller. Either fix the data structure: (def args [:bar 2 :baz [:quux]]) then use apply Or change the function definition to take a map: (defn foo [x