1.2.0 permalink Arrow_down_16x16
  • (permutations items)
All the permutations of items, lexicographic by index

1 Example top

  • Clojure=> (permutations [1 2 3])
    ((1 2 3) (1 3 2) (2 1 3) (2 3 1) (3 1 2) (3 2 1))
    Clojure=> (permutations [1 1 2])
    ((1 1 2) (1 2 1) (1 1 2) (1 2 1) (2 1 1) (2 1 1))
    
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/combinatorics.clj:160 top

(defn permutations
  "All the permutations of items, lexicographic by index"
  [items]
  (let [v (vec items)]
    (map #(map v %) (lex-permutations (range (count v))))))
Vars in clojure.contrib.combinatorics/permutations: count defn let map range
Used in 0 other vars

Comments top

No comments for permutations. Log in to add a comment.