Re: Any clean way to avoid explicit recursion when creating nested loops?

2010-09-30 Thread Nathan Sorenson
That's perfect, thanks! On Sep 30, 4:55 pm, Mark Engelberg wrote: > clojure.contrib.cartesian-product does what your nested function does, > but more efficiently, using iteration rather than recursion. -- You received this message because you are subscribed to the Google Groups "Clojure" group.

Re: Any clean way to avoid explicit recursion when creating nested loops?

2010-09-30 Thread Mark Engelberg
clojure.contrib.cartesian-product does what your nested function does, but more efficiently, using iteration rather than recursion. -- 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

Any clean way to avoid explicit recursion when creating nested loops?

2010-09-30 Thread Nathan Sorenson
I was discussing this on the clojure channel, and it seems as though avoiding explicit recursion is the idiomatic thing to do. Is there a better way to define a function that loops over an arbitrary number of sequences in a nested fashion, similar to the 'for' macro, without relying on recursion?

Re: Nested loops

2009-04-13 Thread David Nolen
Out of simple curiosity I wondered how hard it would be to implement flow control using proxy. I know Rich isn't hot on non-structured programming, but there may be times where this might be useful: (ns flow.return-from (:import (flow IReturnFrom))) (defn create-return-from [value] (proxy [T

Re: Nested loops

2009-04-05 Thread Meikel Brandmeyer
rious about the general case, but you guys may be right that nested loops just aren't needed. My experience in the general case: If I found myself in need for a 'break' or 'continue', it would have been better to put the undesired values not in the loop in the first pl

Re: Nested loops

2009-04-04 Thread David Sletten
My code works--it does function! :-) ). It was kind of a first cut in a more imperative style because I thought it might be more efficient destructively modifying a char array rather than copying lots of substrings. I intended to attempt a more functional version next. I was more curious about the gen

Re: Nested loops

2009-04-04 Thread jim
I didn't take time to read your post in detail because I'm on my way to bed and my brain has already checked out. However, as I've gotten better at Clojure and functional programming, I find I use loops less and less. I just got done putting the finishing touches on a package to analyse stock ch

Re: Nested loops

2009-04-04 Thread Mark Triggs
Hi David, Quite a few times when I've felt the need for this sort of thing I've found that laziness comes to the rescue. Would something like this sort of approach work for you? (defn possibilities [word pos] "All variations of `word' with letters from 'a' to 'z' inserted at `pos'" (let [[b

Nested loops

2009-04-04 Thread David Sletten
I'm working on a spell checker that attempts to suggest corrections from a given dictionary. One of the heuristics is to see if inserting a character at each point in the given string results in a recognized word. So I have an outer loop that moves across each position in the string and an