Skip to content

Instantly share code, notes, and snippets.

@Nolski
Last active May 12, 2016 22:09
Show Gist options
  • Save Nolski/56098d6d15206379046991e6246c0a6e to your computer and use it in GitHub Desktop.
Save Nolski/56098d6d15206379046991e6246c0a6e to your computer and use it in GitHub Desktop.
partition([], H, [], [], []).
partition([TailH | TailT], H, [TailH | Less], Same, Greater) :-
TailH < H,
partition(TailT, H, Less, Same, Greater).
partition([TailH | TailT], H, Less, [TailH | Same], Greater) :-
TailH = H,
partition(TailT, H, Less, Same, Greater).
partition([TailH | TailT], H, Less, Same, [TailH | Greater]) :-
TailH > H,
partition(TailT, H, Less, Same, Greater).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment