Created
February 28, 2014 05:26
-
-
Save trptcolin/9265825 to your computer and use it in GitHub Desktop.
amb implementation with delimc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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