Skip to content

Instantly share code, notes, and snippets.

@tuturto
Last active August 29, 2015 14:01
Show Gist options
  • Save tuturto/a46d27bac8212f552167 to your computer and use it in GitHub Desktop.
Save tuturto/a46d27bac8212f552167 to your computer and use it in GitHub Desktop.
some secondᵒ magic
(import [adderall.dsl [*]])
(require adderall.dsl)
(defreader t [expr] `(, ~@expr))
(defn secondᵒ [l x]
(fresh [r]
(restᵒ l r)
(firstᵒ r x)))
(run* [q]
(fresh (x y)
(appendᵒ x y ["a" "b" "c" "d"])
(condᵉ
[(firstᵒ y "c")]
[(secondᵒ y "c")])
(≡ #t(x y) q)))
;; [(['a'], ['b', 'c', 'd']),
;; (['a', 'b'], ['c', 'd'])]
@algernon
Copy link

FYI, you don't need the #t reader macro, you can just write (≡ (, x y) q).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment