Permutations: Difference between revisions
Content added Content deleted
m (→{{header|Python}}: Add sub-heading.) |
(→{{header|Clojure}}: Leave the library function. It is important to also show what is available in standard libraries if allowed by the task description.) |
||
Line 1,024: | Line 1,024: | ||
=={{header|Clojure}}== |
=={{header|Clojure}}== |
||
===Library function=== |
|||
Replacing the call to the combinatorics library function by its real implementation, as Rosetta is about comparing the ease of implementation of a certain function in the different languages. Just referring to a library hides the implementation. Therefore I have pasted here an implementation after confirming that it works. |
|||
In an REPL: |
|||
<lang clojure> |
|||
user=> (require 'clojure.contrib.combinatorics) |
|||
nil |
|||
user=> (clojure.contrib.combinatorics/permutations [1 2 3]) |
|||
((1 2 3) (1 3 2) (2 1 3) (2 3 1) (3 1 2) (3 2 1))<lang> |
|||
===Explicit=== |
|||
Replacing the call to the combinatorics library function by its real implementation. |
|||
<lang clojure> |
<lang clojure> |
||
(defn- iter-perm [v] |
(defn- iter-perm [v] |