I'm not surprised that the flexible version takes a bit more time than the one that's hardcoded to a for loop nested to 9 levels. The flexible version necessarily involves recursion, which means allocating some stack space with each call, and that's a bit of overhead.
I am a bit surprised that you found no performance difference between the two flexible versions. It looked to me like your version would suffer a significant performance hit from calling str at every level of recursion, rather than just doing it in one pass at the end. I notice that your base case is a sequence of two sets (usually an empty (or nil) sequence is a more elegant base case), so your code won't work for a sequence of zero or one sets, but you have saved on two levels of depth to your recursion, which may be where you make up the performance. By the way, there are general iterative solutions to this problem that will run very fast, but they are more complicated to code. Check out Knuth's fasicle on generating all tuples iteratively. His code is written in a pseudo-assembly, and you might find it fun to convert the code into Clojure (I went through this exercise recently with a permutation iterator because the recursive approach in the contribs wasn't fast enough for me; I found the process enjoyable). --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---