Annoying way to start a morning :P. Thanks though for the tip on
htdp.org
This is what I cooked up, but apparently I can't make it use recur. It
works for small sets, but it becomes prohibitively slow
for collections of 6+ sets of letters.
(defn expand
[sets]
(if (rrest sets)
(for [x (first sets) y (expand (rest sets))] (str x y))
(for [x (first sets) y (second sets)] (str x y))))
On Dec 27, 11:35 pm, "Mark Engelberg" <[email protected]>
wrote:
> On Sat, Dec 27, 2008 at 2:18 PM, bOR_ <[email protected]> wrote:
> > but
> > didn't see an obvious/elegant way to do it in there, and the only way
> > I'd write it now in clojure is going to be ugly.
>
> > Anyone has a suggestion?
>
> This kind of problem is straightforward if you understand recursion,
> and the Clojure code is only a couple of elegant lines. But I'm
> reluctant to "give it away" because it is worth your time to think
> through this on your own. My suggestion is that you look at a book
> like How to Design Programs (htdp.org), and work through some of the
> exercises. Once you do, you'll find problems like this to be trivial.
> Having a solid grounding in recursion will be very valuable when
> working with Clojure.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---