Re: How to flatten a coll only 1 level deep?

2009-04-09 Thread Paul Drummond
2009/4/9 Chouser : > (defn flat1 [coll] >  (mapcat #(if (coll? %) % [%]) coll)) Ah, I see. So for each item, if its already a collection we leave it alone and if not we make a vector of one item, then at the end we use mapcat to concatinate all the top-level items into one list. Excellent - tha

Re: How to flatten a coll only 1 level deep?

2009-04-08 Thread Chouser
On Wed, Apr 8, 2009 at 10:10 PM, Paul Drummond wrote: > > I am looking for something similar to flatten (in contrib.seq-utils) > but the function will only flatten one level deep: > > [ 1 2 3 [4 5 [6 7] ] ] ---> [ 1 2 3 4 5 [6 7] ] > > I have tried combining functions in the seq library and I've

How to flatten a coll only 1 level deep?

2009-04-08 Thread Paul Drummond
I am looking for something similar to flatten (in contrib.seq-utils) but the function will only flatten one level deep: [ 1 2 3 [4 5 [6 7] ] ] ---> [ 1 2 3 4 5 [6 7] ] I have tried combining functions in the seq library and I've studied the code for flatten and tree-seq to look for hints but so