On Wed, Dec 29, 2010 at 7:16 PM, David Nolen <dnolen.li...@gmail.com> wrote: > On Wed, Dec 29, 2010 at 8:13 PM, Mark Engelberg <mark.engelb...@gmail.com> > wrote: >> >> One lesson here: Sometimes Clojure/Java's stack limitations hurt, a >> lot. It's a lot harder to transform this algorithm than it ideally >> should be. > > To be clear, the HTDP implementation of insert sort is stack-consuming in > Scheme/Racket as well. For large enough inputs, Scheme/Racket will also > barf. > David
But Racket's stack is only limited by your overall memory. So if you have enough memory to hold the list you're sorting and the sorted list, you most likely have enough memory to hold the stack of computations necessary to generate the list (since the memory needed for the stack decreases as the output list is built and consumes memory). In other words, this kind of stack-consuming implementation would be a perfectly practical, useful implementation in Racket (assuming you were applying the technique to something more practical than insertion sort:)), whereas in Clojure (and most languages, for that matter), the stack blows up on very realistic list sizes unless you write it a different way. -- 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