Fantastic, thank you!
On Friday, April 12, 2013 11:13:23 PM UTC+1, John Hume wrote:
>
> You can use a map destructuring form on a vector like so:
>
> (let [{x 0 y 1 :or {x 0 y 0}} [7]] [x y])
>
> returns [7 0]
>
> On Fri, Apr 12, 2013 at 5:00 PM, henry clifford
> >
> wrote:
> > I'm trying to
Clojure documentation only talks about
:or followed by a map (from http://clojure.org/special_forms ):
> Also optionally, an *:or* key in the binding form followed by another
> map may be used to supply default values for some or all of the keys if
> they are not found in the init-expr:
>
> (l
You can use a map destructuring form on a vector like so:
(let [{x 0 y 1 :or {x 0 y 0}} [7]] [x y])
returns [7 0]
On Fri, Apr 12, 2013 at 5:00 PM, henry clifford wrote:
> I'm trying to use the :or destructuring syntax as seen here applied to a map
>
> (def point {:y 7})
> (let [{:keys [x y] :or
I'm trying to use the :or destructuring syntax as seen here applied to a map
(def point {:y 7})
(let [{:keys [x y] :or {x 0 y 0}} point]
(println "x:" x "y:" y))
x: 0 y: 7
but I can't get this to work with vectors:
(def point [7])
(let [[x y :or [0 0]] point]
(println "x:" x "y:" y))
what'