Advertisement
Guest User

prologfaisal

a guest
Jul 19th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. john_is_cold.
  2. it_is_raining.
  3. raining(thursday).
  4. raining(saturday).
  5.  
  6. eats(fred, oranges).
  7. eats(fred, apples).
  8. eats(fred, chips).
  9.  
  10. eats(john, apples).
  11. eats(john, icecream).
  12.  
  13. age(john, 32).
  14. age(agnes, 41).
  15. age(fred, 10).
  16. age(tom, 19).
  17.  
  18. greaterThan(X, Age) :-
  19. age(X, Y),
  20. Y > Age.
  21.  
  22. healthy(Name) :-
  23. age(Name, Age),
  24. Age < 20,
  25. eats(Name, apples).
  26.  
  27. parent(john, fred).
  28. parent(mary, fred).
  29. parent(bob, john).
  30.  
  31. grandparent(Gp, Name) :-
  32. % get Grandparent of Name
  33. parent(P, Name),
  34. parent(Gp, P).
  35.  
  36. % factorial =>
  37.  
  38. fac(1,1). % for going down
  39.  
  40. fac(A, B) :-
  41. Ax is A-1,
  42. Ax>0,
  43. fac(Ax, Bx),
  44. B is A*Bx.
  45.  
  46. % Addition
  47.  
  48. add(1,1).
  49.  
  50. add(A, B) :-
  51. Ax is A-1,
  52. Ax>0,
  53. add(Ax, Bx),
  54. B is A+Bx.
  55.  
  56. % Fibonacci
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement