Skip to content

Instantly share code, notes, and snippets.

@trptcolin
Created February 28, 2014 05:26
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 trptcolin/9265825 to your computer and use it in GitHub Desktop.
Save trptcolin/9265825 to your computer and use it in GitHub Desktop.
amb implementation with delimc
(require '[delimc.core :as d])
(defmacro amb [xs]
`(d/shift k# (doseq [x# ~xs]
(k# x#))))
(d/reset
(let [a (amb [1 2 3])
b (amb ["a" "b" "c"])]
(println a b)))
; 1 a
; 1 b
; 1 c
; 2 a
; 2 b
; 2 c
; 3 a
; 3 b
; 3 c
;=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment