Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
19
Task/Permutations/Scheme/permutations-1.scm
Normal file
19
Task/Permutations/Scheme/permutations-1.scm
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
(define (insert l n e)
|
||||
(if (= 0 n)
|
||||
(cons e l)
|
||||
(cons (car l)
|
||||
(insert (cdr l) (- n 1) e))))
|
||||
|
||||
(define (seq start end)
|
||||
(if (= start end)
|
||||
(list end)
|
||||
(cons start (seq (+ start 1) end))))
|
||||
|
||||
(define (permute l)
|
||||
(if (null? l)
|
||||
'(())
|
||||
(apply append (map (lambda (p)
|
||||
(map (lambda (n)
|
||||
(insert p n (car l)))
|
||||
(seq 0 (length p))))
|
||||
(permute (cdr l))))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue