On Wed, Dec 29, 2010 at 12:39 PM, Mark Engelberg
<mark.engelb...@gmail.com> wrote:
> I recommend reading:
> http://htdp.org/2003-09-26/Book/curriculum-Z-H-16.html#node_sec_12.2
> for a detailed discussion of how to design and write insertion sort in
> a functional language, using linked lists and recursion.
>
> One caveat:  Directly translating that code to Clojure will be
> problematic because Clojure uses Java's stack, which overflows quite
> easily when using recursion in anything except Clojure's loop/recur
> construct.  The version of Scheme used for that textbook, on the other
> hand, uses a clever technique to swap out the stack to memory when
> needed, in order to simulate a stack that's essentially unbounded
> except by the size of your computer's memory.  But it's well worth
> learning how adjust code like that to get it to run in Clojure,
> because it's something you'll need to do frequently in order to adapt
> code written in other functional languages.

Who needs to muck about with the stack and recur when you've got laziness? :)

Actually I concur that it could be useful. But laziness is sometimes a
superior alternative to an eager, stack-consuming algorithm and
Clojure makes it fairly easy.

-- 
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