Skip to content

Instantly share code, notes, and snippets.

@metaperl
Created January 1, 2011 00:53
Show Gist options
  • Select an option

  • Save metaperl/761467 to your computer and use it in GitHub Desktop.

Select an option

Save metaperl/761467 to your computer and use it in GitHub Desktop.
% http://sites.google.com/site/prologsite/prolog-problems/1
% working on 1.08
compress([], []).
compress([X,Y], [X,Y]) :- X /= Y.
compress([X,Y], [X]) :- X = Y.
% problems writing other clauses
compress([X,Y|Z], [X,Y|Z1]) :- X /= Y, compress(Z, Z1).
compress([X,Y|Z], Z1) :- X = Y, compress([Y|Z], Z1).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment