Jump to content

Permutations: Difference between revisions

(→‎{{header|Racket}}: We now have a library function, and also a faster+simpler naive impl)
Line 2,440:
 
=={{header|Racket}}==
<lang Racketracket>
#lang racket
 
Line 2,451:
(let loop ([l l] [tail '()])
(if (null? l) (list tail)
(append-map ( λ(x) (loop (remq x l) (cons x tail))) l))))
(perms '(A B C))
;; -> '((C B A) (B C A) (C A B) (A C B) (B A C) (A B C))
Cookies help us deliver our services. By using our services, you agree to our use of cookies.