Skip to content

Instantly share code, notes, and snippets.

@rodnaph
Last active December 12, 2015 02:59
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 rodnaph/4703280 to your computer and use it in GitHub Desktop.
Save rodnaph/4703280 to your computer and use it in GitHub Desktop.
RFC: Relation for flattened lists, only support one level of nesting though... is there an easier way using clojure functions possibly?
; This only support one level...
(defne flatteno
"A relation which matches ys as a flattening of xs, only supports one level"
[xs ys]
([() _] (== ys ()))
([[a . b] _]
(fresh [c]
(flatteno b c)
(appendo a c ys))))
; is there any way in core.logic to use clojure functions, something like...
(defn flatteno [xs ys]
(let [zs (flatten ys)]
(permuteo xs zs)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment