It's unorthodox, but...

(apply concat
  (map (fn [coll f] (f coll))
     (partition 4 (range 1 17))
     (iterate (partial comp list) identity)))

Sean

On Jan 19, 11:58 am, Scott <sbuck...@gmail.com> wrote:
> gotta love well thought out libraries
>
> Thanks Laurent
>
> one more question, what if one was to attempt the reverse, ie:
>
> ( 1 2 3 4 5 6 7 8 9 10 11 12 14 15 16 )
>
> into
>
> ( 1 2 3 4 (5 6 7 8) ((9 10 11 12)) (((13 14 15 16))) )
>
> thanks, sorry just getting started with clojure/lisp
>
> On Jan 19, 11:51 am, Laurent PETIT <laurent.pe...@gmail.com> wrote:
>
> > Maybe you're in quest 
> > ofhttp://richhickey.github.com/clojure-contrib/seq-utils-api.html#cloju...
> > ?
>
> > HTH,
>
> > --
> > Laurent
>
> > 2010/1/19 Scott <sbuck...@gmail.com>:
>
> > > i am utilizing parenthesis to represent a tree structure within a
> > > genetic algorithm
>
> > > I am trying to write a function that can strip all parenthesis such
> > > that I can perform crossovers/mutations on the permutation.
>
> > > Ex.
>
> > > ( 1 2 3 4 (5 6 7 8) ((9 10 11 12)) (((13 14 15 16))) )
>
> > > into
>
> > > ( 1 2 3 4 5 6 7 8 9 10 11 12 14 15 16 )
>
> > > the numbers are unique and can be in any order, and parenthesis can
> > > occur anywhere in the representation [ another possible representation
> > > is ( (5 6 7 8)  1 2 3 4 (((13 14 15 16))) ((9 10 11 12)) )  -- in this
> > > case an operator must order the representation before applying the
> > > removal of parenthesis]
>
> > > so far I hacked something like:
>
> > > (use 'clojure.contrib.str-utils)
>
> > > (defn  genome-to-list [mytree]
> > >  (apply list (re-gsub #"[()]*" "" (str mytree)  )
> > > )
>
> > > but I am sure there is a better option via regression, any ideas?
>
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Clojure" group.
> > > To post to this group, send email to clojure@googlegroups.com
> > > Note that posts from new members are moderated - please be patient with 
> > > your first post.
> > > To unsubscribe from this group, send email to
> > > clojure+unsubscr...@googlegroups.com
> > > For more options, visit this group at
> > >http://groups.google.com/group/clojure?hl=en
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to