On Thursday, May 12, 2016 at 3:59:10 AM UTC-4, dennis wrote:
>
> A try:
>
> (let [raw (list  :a 1 :b 2 :c 3)]
>   (->> raw
>        (partition 2)
>        (filter #(even? (second %)))
>        (map vec)
>        (into {})
>        (merge {:raw raw})))
>
> => {:b 2, :raw (:a 1 :b 2 :c 3)}
>

Brilliant. Actually, I had my own spec wrong. Adjusting for that:

(let [raw (list  :a 1 :b 2 :c 3 :d 42)]
>   (merge {:cz (->> raw
>                    (partition 2)
>                    (filter #(even? (second %)))
>                    (map vec)
>                    (into {}))}
>          (->> raw
>               (partition 2)
>               (map (fn [[k v]] (vector k (when-not (even? v) v))))
>               (into {}))))
> ;; => {:cz {:b 2, :d 42}, :a 1, :b nil, :c 3, :d nil}

 
ie, I want the :cz (formerly :raw) key to hold a selective map of the 
inputs, and then all the inputs as key-values but with some values cleared.

Further repairs welcome.

Thx! -kt

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to