tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 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