Guest User

Untitled

a guest
Nov 20th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. (ns dinesman
  2. (:refer-clojure :exclude [==])
  3. (:use clojure.core.logic))
  4.  
  5. (defne aboveo [x y l]
  6. ([_ _ [y . r]]
  7. (membero x l))
  8. ([_ _ [z . r]]
  9. (!= z y)
  10. (aboveo x y r)))
  11.  
  12. (defne not-above1o [x y l]
  13. ([_ _ ()])
  14. ([_ _ [a . ()]])
  15. ([_ _ [a x . r]] (!= a y))
  16. ([_ _ [_ a . r]]
  17. (!= a x)
  18. (fresh [nl]
  19. (conso a r nl)
  20. (not-above1o x y nl))))
  21.  
  22. (defn not-adjacento [x y l]
  23. (all
  24. (not-above1o x y l)
  25. (not-above1o y x l)))
  26.  
  27. (run* [q]
  28. (fresh [a b c d e]
  29. (== q [a b c d e])
  30. (permuteo [:Baker :Cooper :Fletcher :Miller :Smith] q)
  31. (!= e :Baker) (!= a :Cooper)
  32. (!= e :Fletcher) (!= a :Fletcher)
  33. (aboveo :Miller :Cooper q)
  34. (not-adjacento :Smith :Fletcher q)
  35. (not-adjacento :Fletcher :Cooper q)))
Add Comment
Please, Sign In to add comment