in reply to Rosetta code: Split an array into chunks
Clojure?
Then use it at the REPL:(defn pm-chunk [data chsize] (apply str (interleave (map #(apply str (interpose " " %)) (partition chsize chsize nil data)) (repeat \newline))))
Please note that the rather ugly "apply str" at the top is necessary to fulfil the perlish requirements. Usually you'd stop at creating the right sequence, which is achieved after the call to interleave.user=> (print (pm-chunk ["a" "bb" "c" "d" "e" "f" "g" "h"] 3)) a bb c d e f g h
Regards... | stefan k |
you begin bashing the string with a +42 regexp of confusion |
|
---|
In Section
Meditations