Next | Tricks of the Wizards | 171 |
Suppose you want to generate strings of a certain form
I got this example from a biologist
He wanted "AT(GC)A(TA)" to become ATGAT, ATGAA, ATCAT, ATGCAA.
He had built a recursive subroutine to generate all the strings of a given form
It took a long time to run and generated a uselessly large list
Iterators are a better solution
As an example, will expand "foo-#-bar#" instead:
foo-0-bar0
foo-0-bar1
...
foo-9-bar8
foo-9-bar9
Next | Copyright © 2003 M. J. Dominus |