Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created April 5, 2012 03: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 swannodette/2307725 to your computer and use it in GitHub Desktop.
Save swannodette/2307725 to your computer and use it in GitHub Desktop.
concato.clj
(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)))
@jonase
Copy link

jonase commented Apr 5, 2012

I think this version also suffers from non-termination, for example:

(run* [q]
  (fresh [x y]
    (concato x y x '[b a a a a a b])
    (== q y)))

Should return something like ([b a a a a a b] [a a a a a]) but it doesn't terminate

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