SHARE
TWEET

Untitled

a guest Oct 21st, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %35
  2. domains
  3. int = integer
  4. list=int*
  5.  
  6. Predicates
  7. nondeterm enter(list)
  8. nondeterm run
  9. nondeterm do(char)
  10. nondeterm append(list, list, list)
  11.  
  12. clauses
  13. enter([H|T]):-
  14. write("Enter elements of the list or type 'end': "),
  15. readint(H),
  16. enter(T).
  17. enter([]):-!.
  18.  
  19. append([], [], []):-!.
  20. append([A], [B], [A,B]):-!.
  21. append([A|T], [B|T2], [A, B|T1]):-
  22. append(T, T2, T1).
  23.  
  24. run:-
  25. write("*******ENTER*******"), nl,
  26. write("- 1 to START"),nl,
  27. write("- 0 to EXIT"),nl,
  28. write("***********************"),nl,
  29. write(">>"), readchar(X),
  30. write(X), nl, do(X), run.
  31.  
  32. do('1'):-
  33. enter(L),write("Your list 1 is ",L),nl,
  34. enter(L1),write("Your list 2 is ",L1),nl,
  35. append(L,L1,L2),nl,
  36. write("New list is ",L2),nl.
  37.  
  38. do('0'):-
  39. write("That's all"),exit.
  40.  
  41. do(_):-
  42. write("Bad value"), nl.
  43. goal
  44. run.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top