Advertisement
Guest User

Untitled

a guest
Aug 4th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.22 KB | None | 0 0
  1. %P9: Pack consecutive duplicates of list elements into sublists.
  2. pack([],[]).
  3. pack([H,H|T], R) :- append([H], T, L), pack(L, [X|Y]),
  4.                     append([H], X, P), append([P], Y, R).
  5. pack([H|T], [[H]|R]):- pack(T, R).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement