Guest User

Untitled

a guest
Jan 13th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.92 KB | None | 0 0
  1. class("Monday", ["System Programming", "Principles of Programming Languages"]).
  2. class("Tuesday", ["Artificial Intelligence", "Human Computer Interaction"]).
  3. class("Wednesday", ["Database Technologies"]).
  4. class("Thursday", ["Artificial Intelligence", "Human Computer Interaction"]).
  5. class("Friday", ["System Programming", "Principles of Programming Languages"]).
  6.  
  7. days(["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]).
  8.  
  9. member(A, [A|Tail]).
  10. member(A, [Head|Tail]):-
  11.     member(A, Tail).
  12.  
  13. append([],X,X).
  14. append([X|Y],Z,[X|W]) :- append(Y,Z,W).
  15.  
  16.  
  17. daysOfClass(Days, [H|[]], Class):-
  18.     Days = [],
  19.     Message = "No Class Found!",
  20.     write(Message);
  21.     write(Days).
  22.  
  23. daysOfClass(Days, [H|T], Class):-
  24.     class(H, Classes),
  25.     member(Class, Classes),
  26.     append(Days, [H], Result),
  27.     daysOfClass(Result, T, Class);
  28.     daysOfClass(Days, T, Class).
  29.  
  30. ?- days(D),
  31. daysOfClass(Days, D, "System Programming").
Add Comment
Please, Sign In to add comment