Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mrb
Last active December 12, 2015 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrb/4740935 to your computer and use it in GitHub Desktop.
Save mrb/4740935 to your computer and use it in GitHub Desktop.
Pad a hint list with 0s and permute.
(defn pad-with-zeroes-and-permute [h n]
(run* [q]
(fresh [p]
(== p (lvars n))
(appendo (take (- n (count h)) (repeat 0)) h p)
(permuteo p q))))
(pad-with-zeroes-and-permute '(1 1) 5)
;((0 0 0 1 1) (0 0 1 0 1) (0 1 0 0 1) (1 0 0 0 1) (0 0 1 1 0) (0 1 0 1 0) (1 0 0 1 0) (0 1 1 0 0) (1 0 1 0 0) (1 1 0 0 0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment