Advertisement
norswap

Prolog in Clojure Evaluation

May 15th, 2017 (edited)
476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (<- (father albert barnaby))
  2. (<- (father albert babar))
  3.  
  4. (<- (mother anna   barnaby))
  5. (<- (mother anna   babar))
  6.  
  7. (<- (father alain  bob))
  8. (<- (father alain  ben))
  9.  
  10. (<- (mother alice  bob))
  11. (<- (mother alice  ben))
  12.  
  13. (<- (father ben    carla))
  14. (<- (mother carla  dany))
  15.  
  16. (<- (parent Parent Child) (father Parent Child))
  17. (<- (parent Parent Child) (mother Parent Child))
  18.  
  19. (<- (ancestor X Z) (parent X Z))
  20. (<- (ancestor X Z) (parent X Y) (ancestor Y Z))
  21.  
  22. (<- (append (list) T T))
  23. (<- (append (list H T) L2 (list H TR))
  24.     (append T L2 TR))
  25.  
  26. (<- (reverse (list) L2 L2 (list)))
  27. (<- (reverse (list H1 T1) A L2 (list X T2))
  28.     (reverse T1 (list H1 A) L2 T2))
  29. (<- (reverse L1 L2)
  30.     (reverse L1 (list) L2 L2))
  31.  
  32. ;; ancestors
  33. (?- (ancestor alice dany))
  34. (?- (ancestor A     dany))
  35. (?- (ancestor alice D))
  36.  
  37. (?- (father albert babar))
  38. (?- (father A      babar))
  39. (?- (father albert B))
  40.  
  41. (?- (parent anna babar))
  42. (?- (parent A    babar))
  43. (?- (parent anna B))
  44.  
  45. ;; append
  46. (?- (append (list 1 (list 2 (list))) (list 3 (list 4 (list))) R))
  47. (?- (append L1 (list 3 (list 4 (list))) (list 1 (list 2 (list 3 (list 4 (list)))))))
  48. (?- (append (list 1 (list 2 (list))) L2 (list 1 (list 2 (list 3 (list 4 (list)))))))
  49. (?- (append (list 1 (list 2 (list))) L2 (list 1 (list 2 (list 3 (list 4 (list)))))))
  50. (?- (append L1 L2 (list 1 (list 2 (list 3 (list 4 (list)))))))
  51.  
  52. ;; reverse
  53. (?- (reverse (list 1 (list 2 (list 3 (list 4 (list))))) R))
  54. (?- (reverse R (list 1 (list 2 (list 3 (list 4 (list)))))))
  55. (?- (reverse X Y))
  56. (?- (reverse (list 1 (list 2 X)) (list 4 (list 3 Y))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement