Created
April 5, 2012 03:26
-
-
Save swannodette/2307725 to your computer and use it in GitHub Desktop.
concato.clj
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
(defn concato | |
([a b o] | |
(appendo a b o)) | |
([a b c & rest] | |
(let [g (fresh [l] | |
(appendo a b l) | |
(apply concato l c rest)) | |
g' (fresh [l] | |
(apply concato l c rest) | |
(appendo a b l))] | |
(conde | |
[(lvaro a) (lvaro b) g'] | |
[(nonlvaro a) (lvaro g) g] | |
[(lvaro a) (nonlvaro b) g] | |
[(nonlvaro a) (nonlvaro b) g])))) | |
;; (run* [q] | |
;; (concato '(1 2 3) '(4 5 6) '(7 8 9) q)) | |
;; (run* [q] | |
;; (fresh [x y] | |
;; (concato x y x '[b a a a a a b]) | |
;; (== q y))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think this version also suffers from non-termination, for example:
Should return something like
([b a a a a a b] [a a a a a])
but it doesn't terminate