Re: loop recur vs recursion

2008-11-30 Thread [EMAIL PROTECTED]
On Nov 30, 7:47 pm, Chouser <[EMAIL PROTECTED]> wrote: > On Sun, Nov 30, 2008 at 5:52 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Any other solutions that would avoid a helper function?  Not just > > for my particular case, but anytime that one is calling recur from a > > catch clause

Re: loop recur vs recursion

2008-11-30 Thread Chouser
On Sun, Nov 30, 2008 at 5:52 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Any other solutions that would avoid a helper function? Not just > for my particular case, but anytime that one is calling recur from a > catch clause? Generally, collect the information you need from the catch cla

Re: loop recur vs recursion

2008-11-30 Thread [EMAIL PROTECTED]
On Nov 30, 3:51 pm, "Michael Wood" <[EMAIL PROTECTED]> wrote: > On Sun, Nov 30, 2008 at 9:29 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > On Nov 29, 7:52 am, Rich Hickey <[EMAIL PROTECTED]> wrote: > >> On Nov 29, 2008, at 6:49 AM, Daniel Renfer wrote: > > >> > Even if you don't think y

Re: loop recur vs recursion

2008-11-30 Thread Michael Wood
On Sun, Nov 30, 2008 at 9:29 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > On Nov 29, 7:52 am, Rich Hickey <[EMAIL PROTECTED]> wrote: >> On Nov 29, 2008, at 6:49 AM, Daniel Renfer wrote: >> >> > Even if you don't think you'll run into the possibility of blowing >> > your stack, it's still a

Re: loop recur vs recursion

2008-11-30 Thread [EMAIL PROTECTED]
On Nov 29, 7:52 am, Rich Hickey <[EMAIL PROTECTED]> wrote: > On Nov 29, 2008, at 6:49 AM, Daniel Renfer wrote: > > > Even if you don't think you'll run into the possibility of blowing > > your stack, it's still a good idea to use recur when doing tail call > > recursion. The compiler will help you

Re: loop recur vs recursion

2008-11-30 Thread bOR_
> > (defn construct-atom >   "translates a number n into an set of letters of size n" >   [construct length] >   (if (< (count construct) length) >     (recur (conj construct (char (+ (rand-int amino_acids) 65))) length) >     construct)) > > recur will goto the nearest enclosing loop or fn. > >

Re: loop recur vs recursion

2008-11-29 Thread .Bill Smith
As often as this comes up, I wonder if TCO and loop/recur deserve their own section in the reference section. Bill On Nov 29, 4:11 am, "Kevin Downey" <[EMAIL PROTECTED]> wrote: > the jvm does not do TCO, loop/recur allows for functional looking > recursion on the jvm with constant stack size. >

Re: loop recur vs recursion

2008-11-29 Thread Rich Hickey
On Nov 29, 2008, at 6:49 AM, Daniel Renfer wrote: > Even if you don't think you'll run into the possibility of blowing > your stack, it's still a good idea to use recur when doing tail call > recursion. The compiler will help you out by making sure it really is > a tail call. > > Remember, recur

Re: loop recur vs recursion

2008-11-29 Thread Daniel Renfer
Even if you don't think you'll run into the possibility of blowing your stack, it's still a good idea to use recur when doing tail call recursion. The compiler will help you out by making sure it really is a tail call. Remember, recur isn't just for loop. It works with functions too. On Sat, Nov

Re: loop recur vs recursion

2008-11-29 Thread bOR_
In this case, the depth of the recursion would be at maximum 21 (number of different types of amino acids), and the function itself not often called. Is stack size something to worry about at those depths? On Nov 29, 11:11 am, "Kevin Downey" <[EMAIL PROTECTED]> wrote: > the jvm does not do TCO, l

Re: loop recur vs recursion

2008-11-29 Thread Kevin Downey
the jvm does not do TCO, loop/recur allows for functional looking recursion on the jvm with constant stack size. On Sat, Nov 29, 2008 at 1:25 AM, bOR_ <[EMAIL PROTECTED]> wrote: > > Hi all, > > I wondered if there is a difference between using loop-recur or merely > writing a recursive function. T