Permutations: Difference between revisions

m ('''See Also:''' {{Template:Combinations and permutations}})
Line 2,439:
# 3 2 1</lang>
 
=={{header|Racket}}==
<lang racket>#lang racket
 
(define (permutations ℓ)
(if (empty? ℓ) (list ℓ)
(append-map (λ (e) (map (curry cons e)
(permutations (remove e ℓ))))
ℓ)))</lang>
Try it:
<lang racket>(printf "Perumutations of ~a:\n~a\n\n" '(r o c) (permutations '(r o c)))
(printf "Time [in milliseconds] to generate permutations of 9 numbers:\n")
(time (void (length (permutations (range 0 9)))))</lang>
Output:
<pre>Perumutations of (r o c):
((r o c) (r c o) (o r c) (o c r) (c r o) (c o r))
 
Time [in milliseconds] to generate permutations of 9 numbers:
cpu time: 1672 real time: 1719 gc time: 816</pre>
=={{header|REXX}}==
===names===
Anonymous user