Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % 1.08 (**): Eliminate consecutive duplicates of list elements.
- % compress(L1,L2) :- the list L2 is obtained from the list L1 by
- % compressing repeated occurrences of elements into a single copy
- % of the element.
- % (list,list) (+,?)
- compress([],[]).
- compress([X],[X]).
- compress([X,X|Xs],Zs) :- compress([X|Xs],Zs).
- compress([X,Y|Ys],[X|Zs]) :- X \= Y, compress([Y|Ys],Zs).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement