Permutations with repetitions: Difference between revisions
→Applescript lazy evaluation: pruned a redundant function, edited a sub-title
(Applescript →Strict evaluation of the whole set: updated) |
(→Applescript lazy evaluation: pruned a redundant function, edited a sub-title) |
||
Line 96:
<lang AppleScript>{{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}}</lang>
===
Permutations with repetition by treating the <math>n^k</math> elements as an ordered set, and writing a function from a zero-based index to the nth permutation. This allows us terminate a repeated generation on some condition, or explore a sub-set without needing to generate the whole set:
<lang AppleScript>use AppleScript version "2.4"
Line 254:
return out & dbl
end replicate
-- toLower :: String -> String
|