in reply to How to show all possible replacements?

Does speed really matter? If you're only going to run this once, then understanding the code is much more important.

If it's slow in real terms, then you must be processing lots of data, so I assume you'll generate lots of alternative strings. But what are you really looking for ? There may be better ways to solve your underlying problem.

Anyway, glob is one simple way to get a list of alternatives. The help says :-

If non-empty braces are the only wildcard characters used in the "glob +", no filenames are matched, but potentially many strings are returned. For example, this produces nine strings, one for each pairing of fruit +s and colors: @many = glob "{apple,tomato,cherry}={green,yellow,red}";

Replies are listed 'Best First'.
Re^2: How to show all possible replacements?
by BurningBeard (Novice) on May 12, 2013 at 15:01 UTC
    Thank you for your reply, I'll check glob out.
    I have created an algorithm that processes quite large binary words, to acquire complexity-related characteristics from them, one being the amount of ways to create this word using only concatenation, and in minimal amount of operations used.

    The complete algorithm basically divides the original word into two parts, recursively uses itself to look for easiest ways to concatenate the smallest word(left in case the word was halved on step 1). The concatenation scheme of the smallest word is called later as prehistory of this word - the list of word already created, and those can be used to create the second word.
    The question posted arose, when I started to test this algorithm on larger words, say:
    Word = 01101001, maximum complexity is 5.
    1. A = 01; B = 101001.
    2. P(A) = {0,1;01}, C(A) = 1;
    3. Map generated:
    01 -> a;
    4. If B is replaced only the greediest way possible: 1a0a, it can be created in 3 steps, but, the algorithm misses a scheme, since the word 1010a can also be created in 3 steps, so it also does not break the rule:
    C(A) + C(B) = C(W) + 1