Re: loop/recur with multiple branches

2013-12-11 Thread Vincent Chen
On Tue, Dec 10, 2013 at 11:46 PM, Cedric Greevey wrote: > On Tue, Dec 10, 2013 at 6:29 PM, Vincent Chen wrote: >> >> Try this (not tested, might be missing parens and whatnot): >> >> (defn slice [x s n] >> (loop [[h & tail] x, s s, n n, acc []] >> (cond >> (zero? n) acc >> (zero

Re: loop/recur with multiple branches

2013-12-10 Thread Cedric Greevey
On Tue, Dec 10, 2013 at 6:29 PM, Vincent Chen wrote: > Try this (not tested, might be missing parens and whatnot): > > (defn slice [x s n] > (loop [[h & tail] x, s s, n n, acc []] > (cond > (zero? n) acc > (zero? s) (recur tail s (dec n) (conj acc h)) > :else (recur tail (

Re: loop/recur with multiple branches

2013-12-10 Thread Vincent Chen
On Tue, Dec 10, 2013 at 11:09 PM, Glen Mailer wrote: > I was recently working on some toy recursion problems, when I ran into a > function that I can express simply using normaly recursion, but I can't seem > to convert it into a form that works nicely with loop/recur. > > It's certainly not the r

Re: loop/recur with multiple branches

2013-12-10 Thread Cedric Greevey
On Tue, Dec 10, 2013 at 6:09 PM, Glen Mailer wrote: > I was recently working on some toy recursion problems, when I ran into a > function that I can express simply using normaly recursion, but I can't > seem to convert it into a form that works nicely with loop/recur. > > It's certainly not the r

loop/recur with multiple branches

2013-12-10 Thread Glen Mailer
I was recently working on some toy recursion problems, when I ran into a function that I can express simply using normaly recursion, but I can't seem to convert it into a form that works nicely with loop/recur. It's certainly not the right way to solve this problem, but I'm intrigued to see wha