Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
11
Task/Permutations/Mathematica/permutations-1.math
Normal file
11
Task/Permutations/Mathematica/permutations-1.math
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
(***Standard list functions:*)
|
||||
fold[f_, x_, {}] := x
|
||||
fold[f_, x_, {h_, t___}] := fold[f, f[x, h], {t}]
|
||||
insert[L_, x_, n_] := Join[L[[;; n - 1]], {x}, L[[n ;;]]]
|
||||
|
||||
(***Generate all permutations of a list S:*)
|
||||
|
||||
permutations[S_] :=
|
||||
fold[Join @@ (Function[{L},
|
||||
Table[insert[L, #2, k + 1], {k, 0, Length[L]}]] /@ #1) &, {{}},
|
||||
S]
|
||||
1
Task/Permutations/Mathematica/permutations-2.math
Normal file
1
Task/Permutations/Mathematica/permutations-2.math
Normal file
|
|
@ -0,0 +1 @@
|
|||
Permutations[{1,2,3,4}]
|
||||
Loading…
Add table
Add a link
Reference in a new issue