Hi,

2011/9/14 Alan Malloy <a...@malloys.org>

> You can prefer anything you want, but (a) to say that Clojure prefers
> loop/recur is nonsense, and (b) you can't make an incorrect algorithm
> work just by preferring it. Jeff is correct that your algorithm
> requires space for each level of the tree, and so cannot be converted
> into a constant-space algorithm. You can convert it into loop/recur by
> using up a bunch of heap instead of a bunch of stack, but there's
> rarely much point to doing that.
>

Well, not quite, since with the JVM it's faster to consume the stack and get
a StackOverflowException, than it is to get an OutOfMemoryException, no ?

It's certainly possible to convert this algorithm without consuming stack
proportionnally to the depth of the tree. But as you said, in the end this
would probably reimplement something along the lines of clojure.zip. Maybe
more specialized, maybe faster ...


>
> On Sep 14, 9:38 am, octopusgrabbus <octopusgrab...@gmail.com> wrote:
> > Jeff:
> >
> > loop .. recur syntax is Clojure's preferred method of recursion.
> >
> > This is a routine to return the skeleton of a sequence, not its values.
> >
> > cmn
>
> --
> 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