parsing - Clojure Mapping a function that returns a list into a flat list -


this happens when parse list of strings , want split each 1 in two, afterwards making hashmap.

say have list of strings, each 1 first line id , rest data:

("#id data more data", "#another id more data still") 

now suppose use following method returns nested structure:

(map #(clojure.string/split % #"\n" 2) data)  

now if want put hashmap, first has flatten'd , apply hash-map'd. there way skip flatten part , having flat-map return non-nested structure?

you can use into:

(into {} (map #(clojure.string/split % #"\n") data))  

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -