Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Permutations/Qi/permutations.qi
Normal file
19
Task/Permutations/Qi/permutations.qi
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
(define insert
|
||||
L 0 E -> [E|L]
|
||||
[L|Ls] N E -> [L|(insert Ls (- N 1) E)])
|
||||
|
||||
(define seq
|
||||
Start Start -> [Start]
|
||||
Start End -> [Start|(seq (+ Start 1) End)])
|
||||
|
||||
(define append-lists
|
||||
[] -> []
|
||||
[A|B] -> (append A (append-lists B)))
|
||||
|
||||
(define permutate
|
||||
[] -> [[]]
|
||||
[H|T] -> (append-lists (map (/. P
|
||||
(map (/. N
|
||||
(insert P N H))
|
||||
(seq 0 (length P))))
|
||||
(permute T))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue