Neat!
TIL: the :as
keyword in Clojure's destructuring allows recursive destructuring.
((fn [[[x1 y1] [x2 y2] :as [c1 c2 :as cs]]] {:x1 x1 :y1 y1 :x2 x2 :y2 y2 :c1 c1 :c2 c2 :cs cs}) [[1 2] [3 4]])
outputs
{:x1 1, :y1 2, :x2 3, :y2 4, :c1 [1 2], :c2 [3 4], :cs [[1 2] [3 4]]}
that's pretty wild
arronmabrey++
isn't that the same as [[x1 y1 :as c1] [x2 y2 :as c2] :as cs]?
@gfredericks: yup, I get the same output with that as well. It just goes to show how flexible Clojure's destructuring is.
I've never thought of using anything but a symbol after the :as
. That's pretty awesome
Hi, using cheshire, is there a way to decode json with a date string and convert it to the Date. object?
@sveri, check out https://github.com/clj-time/clj-time.
@sveri: schema + coercions maybe?
@sveri: you can look around a thing I've done for university, I had to solve this exact thing. It's mostly contained to this directory - https://github.com/jaen/panda-5/tree/master/src/panda_5/api.
Basically set up schemas and then set up coercions.
http://github.com/gfredericks/schema-bijections is an alternative approach