chickadee » mini-kanren » permuteo

permuteo xl ylprocedure

Goal that permutes xl into yl. It may not terminate if xl is not ground.

Example:

;; Get 5-permute-2, i.e. all 2 permutations of the numbers 1 through 5.
(run* (q)
  (lengtho q (build-num 2))
  (permuteo '(1 2 3 4 5) q))

; => (1 2) (2 1) (2 3) (1 3) (3 1) (3 2) (3 4) (2 4) (1 4) (4 1) (4 2)
;    (4 3) (3 5) (4 5) (2 5) (1 5) (5 1) (5 2) (5 3) (5 4))