Re: Function that "weaves" two collections together - looking for feedback

2014-02-19 Thread Steve Miner
On Feb 19, 2014, at 12:28 AM, Laurent Droin wrote: > Ah, thank you. "interleave" is what I was looking for. I looked for "weave", > "zip", "map", "concat", and all the "see also" but did not find "interleave". > Interleave will of course not handle the last value in the categories > collection

Re: Function that "weaves" two collections together - looking for feedback

2014-02-18 Thread Mark Engelberg
(concat sequence [val]) would often be preferable to (conj (into [] sequence) val) because the former solution maintains laziness. On Tue, Feb 18, 2014 at 9:28 PM, Laurent Droin wrote: > Ah, thank you. "interleave" is what I was looking for. I looked for > "weave", "zip", "map", "concat", and

Re: Function that "weaves" two collections together - looking for feedback

2014-02-18 Thread Laurent Droin
Ah, thank you. "interleave" is what I was looking for. I looked for "weave", "zip", "map", "concat", and all the "see also" but did not find "interleave". Interleave will of course not handle the last value in the categories collection so my first instinct will be to call (into [] ) on the map

Re: Function that "weaves" two collections together - looking for feedback

2014-02-18 Thread Michael Gardner
You may be interested in the core function 'interleave'. As for (into []), it's perfectly idiomatic as long as you actually need to return a vector and not just some kind of sequence (the more common case). But note also the mapv/filterv/reduce-kv family of functions, though they're not directly

Function that "weaves" two collections together - looking for feedback

2014-02-18 Thread Laurent Droin
Hi, Continuing my little pet project (small program really) to learn Clojure, I am now working on a function whose description would be something like: "Returns a collection 'weaving' 2 collections (boundaries into categories). Boundaries must have one element less than categories. For exa