Re: take 1 element from each coll, make all possible strings?

2008-12-29 Thread bOR_
Timothy - It becomes more tricky if you want to know what fraction of everything a host can present that carries 2 or 3 different filters (I mentioned that somewhere). For example: everything is 4^4 = 256 options [ABCD][ABCD][ABCD][ABCD] Host carries these two filters: [ABC][AC][AB][ABC]

Re: take 1 element from each coll, make all possible strings?

2008-12-28 Thread Mark Engelberg
On Sun, Dec 28, 2008 at 12:49 AM, bOR_ boris.sch...@gmail.com wrote: Annoying way to start a morning :P. Thanks though for the tip on htdp.org I'm not trying to be annoying. I just don't know how valuable the answer will be to you, until you've got a better handle on recursion. The code

Re: take 1 element from each coll, make all possible strings?

2008-12-28 Thread bOR_
Thanks. I understood your intentions, and it didn't hurt for me to find my own solution. (time (count (expand (first myset Elapsed time: 2426.327 msecs 403200 Timing yours it is about as fast as the flexible for version, but not as fast as the tailored for version. Perhaps I should look at

Re: take 1 element from each coll, make all possible strings?

2008-12-28 Thread bOR_
Ah. The prohibitively long bit comes mainly from printing out the whole list in emacs. Counting it is only a few seconds, and not that much slower than for the fixed-length version. In computer-time it is still taking ages though. Why am I going through all of this?: I have 3 filters in the form

Re: take 1 element from each coll, make all possible strings?

2008-12-28 Thread Mark Engelberg
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

Re: take 1 element from each coll, make all possible strings?

2008-12-28 Thread Mark Engelberg
I coded up a quickie iterative version for you so you can get an idea what that looks like. My timing tests indicate that this runs many times faster than even the hardcoded for loop nested to 9 levels. ; Convert to a vector, and pass off to step, which builds a lazy sequence by applying

Re: take 1 element from each coll, make all possible strings?

2008-12-28 Thread Mark Engelberg
This iterative version doesn't behave properly if one of the sequences is empty. Expand should probably check for this degenerate case before passing the vector off to step. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

Re: take 1 element from each coll, make all possible strings?

2008-12-28 Thread bOR_
On Dec 28, 12:26 pm, Mark Engelberg mark.engelb...@gmail.com wrote: This iterative version doesn't behave properly if one of the sequences is empty.  Expand should probably check for this degenerate case before passing the vector off to step. I'll take care of that Interesting. on my comp,

Re: take 1 element from each coll, make all possible strings?

2008-12-28 Thread Timothy Pratley
If you aren't interested in the permutations themselves, just the number of them (if I read you right) The only way I could think up to know exactly what fraction of the optimum (2x 5%: remember the diploidi)) a set of combined filters can present is by expanding these filters into a set

take 1 element from each coll, make all possible strings?

2008-12-27 Thread bOR_
Hi all, Next problem. If I've a collection of sets of letters, and I want all possible words you can make with this collection if you keep the order of the sets intact, I would use 'for'. However, for wants me to know beforehand how many sets there are in my collection. Is there a more flexible

Re: take 1 element from each coll, make all possible strings?

2008-12-27 Thread Mark Engelberg
On Sat, Dec 27, 2008 at 2:18 PM, bOR_ boris.sch...@gmail.com 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