Re: stripping parenthesis

2010-01-19 Thread Scott
thanks all! On Jan 19, 2:06 pm, kyle smith wrote: > http://groups.google.com/group/clojure/browse_thread/thread/806ebb1cb... -- 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

Re: stripping parenthesis

2010-01-19 Thread kyle smith
http://groups.google.com/group/clojure/browse_thread/thread/806ebb1cbe671969/82a25385a2a8a18d?lnk=gst&q=unflatten#82a25385a2a8a18d -- 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 p

Re: stripping parenthesis

2010-01-19 Thread Konrad Hinsen
On 19.01.2010, at 17:58, Scott wrote: 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))) ) There are certainly many ways to do it. Here is one: (defn insert [[f & r]] (if (empty? r

Re: stripping parenthesis

2010-01-19 Thread Sean Devlin
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 wrote: > gotta love well thought out libraries > > Thanks Laurent > > one more question, what if one was to attempt t

Re: stripping parenthesis

2010-01-19 Thread Scott
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, La

Re: stripping parenthesis

2010-01-19 Thread Laurent PETIT
Maybe you're in quest of http://richhickey.github.com/clojure-contrib/seq-utils-api.html#clojure.contrib.seq-utils/flatten ? HTH, -- Laurent 2010/1/19 Scott : > i am utilizing parenthesis to represent a tree structure within a > genetic algorithm > > I am trying to write a function that can str

stripping parenthesis

2010-01-19 Thread Scott
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