Created
April 5, 2012 04:24
-
-
Save nickknw/2307907 to your computer and use it in GitHub Desktop.
Odd prolog syntax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Following code sample from 'Higher Order Logic Programming In Prolog' by Lee Naish | |
% www.csee.umbc.edu/771/papers/mu_96_02.pdf | |
% insertion sort (simple version) | |
isort([], []). | |
isort(A.As, Bs) :- | |
isort(As, Bs1), | |
isort(A, Bs1, Bs). | |
% insert number into sorted list | |
insert(N, [], [N]). | |
insert(N, H.L, N.H.L) :- | |
N =< H. | |
insert(N, H.LO, H.L) :- | |
N > H, | |
insert(N, LO, L). | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment