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, 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. The main difference I found thus far was
> > that the loop-recur can suffice with less arguments, but the recursive
> > functions seem to be shorter, and perhaps more elegant?
>
> > (defn construct-atom
> >  "translates a number n into an set of letters of size n"
> >  [construct length]
> >  (if (< (count construct) length)
> >    (construct-atom (conj construct (char (+ (rand-int amino_acids)
> > 65))) length)
> >    construct))
>
> > (defn construct-atom-loop
> >  "translates a number n into an set of letters of size n"
> >  [n]
> >  (let [base_construct #{}]
> >    (loop [construct base_construct]
> >      (if (< (count construct) n)
> >        (recur (conj construct (char (+ (rand-int amino_acids) 65))))
> >        construct))))
>
> --
> And what is good, Phaedrus,
> And what is not good—
> Need we ask anyone to tell us these things?
--~--~---------~--~----~------------~-------~--~----~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to