Fork me on GitHub
#admin-announcements
<
2015-12-18
>
arronmabrey15:12:43

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]]}

alexmiller15:12:36

that's pretty wild

gfredericks18:12:38

isn't that the same as [[x1 y1 :as c1] [x2 y2 :as c2] :as cs]?

arronmabrey18:12:15

@gfredericks: yup, I get the same output with that as well. It just goes to show how flexible Clojure's destructuring is.

samflores19:12:59

I've never thought of using anything but a symbol after the :as. That's pretty awesome

sveri19:12:04

Hi, using cheshire, is there a way to decode json with a date string and convert it to the Date. object?

jaen20:12:55

@sveri: schema + coercions maybe?

jaen20:12:22

@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.

jaen20:12:37

Basically set up schemas and then set up coercions.