Created
March 22, 2013 03:49
-
-
Save deltamualpha/5218827 to your computer and use it in GitHub Desktop.
I suck at clojure.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn magic [row] | |
(if (map? (first row)) (for [x row] (into [] (flatten (seq x)))) (into [] x))) | |
(defn collapser [incoming] | |
(reduce (fn [a b] (conj a (magic b))) [["header" "information"]] (remove nil? incoming))) | |
;for an input like | |
;([:a a :b b] nil nil [{:c c, :d d} {:e e, :f f}] nil [:a g :b h]) => | |
;[["test" "two"] [:a "a" :b "b"] ([:c "c" :d "d"] [:e "e" :f "f"]) [:a "g" :b "h"]] | |
;but what I want is | |
;[["test" "two"] [:a "a" :b "b"] [:c "c" :d "d"] [:e "e" :f "f"] [:a "g" :b "h"]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Will this work for you? It assumes that there will always be "two pairs" of some kind in sets of two.
In action: