Skip to content

Instantly share code, notes, and snippets.

@mrb
Forked from swannodette/notes.clj
Created January 31, 2013 22:07
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/4687017 to your computer and use it in GitHub Desktop.
Save mrb/4687017 to your computer and use it in GitHub Desktop.
(defn sumo
([l n] (sumo l 0 n))
([l acc n]
(matche [l]
([[]] (fd/== acc n))
([[x . r]]
(fresh [nacc]
(fd/in x (fd/interval 0 1))
(fd/+ acc x nacc)
(sumo r nacc n))))))
(defn sum-list [m n]
(let [l (repeatedly m lvar)]
(run* [q]
(== q l) (sumo q n))))
;; (every? #(and (= (count %) 5) (= (reduce + %) 10)) (sum-list 5 10)) => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment