Advertisement
bohdanpyryn

Prolog code snippets

Feb 4th, 2020
738
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.54 KB | None | 0 0
  1. Побудова оберненого списку на основі вхідного. Для цього використовуйте принцип рекурсії та операцію конкатенації двох списків.
  2. domains
  3. nList = integer*.
  4. class predicates
  5. task8 : (nList, nList [out]) nondeterm.
  6. concat : (nList, nList, nList) nondeterm anyflow.
  7. clauses
  8. concat([], L2, L2].
  9. concat([H | L1, L2, [H | L3] :-
  10. concat(L1, L2, L3).
  11. task8([], []).
  12. task8([H | T], Res) :-
  13. task8(T, Res1),
  14. concat(Res1, [H], Res).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement