Anonymous user
Permutations: Difference between revisions
→{{header|Racket}}: We now have a library function, and also a faster+simpler naive impl
(→{{header|Racket}}: Added.) |
(→{{header|Racket}}: We now have a library function, and also a faster+simpler naive impl) |
||
Line 2,440:
=={{header|Racket}}==
<lang
#lang racket
;; using a builtin
(define (permutations ℓ)▼
(permutations '(A B C))
(if (empty? ℓ) (list ℓ)▼
;; -> '((A B
;; a random simple version (which is actually pretty good for a simple version)
(let loop ([l l] [tail '()])
(append-map ( (x) (loop (remq x l) (cons x tail))) l))))
(perms '(A B C))
</lang>
▲((r o c) (r c o) (o r c) (o c r) (c r o) (c o r))
=={{header|REXX}}==
===names===
|