diff options
-rw-r--r-- | prolog/.gitignore | 2 | ||||
-rw-r--r-- | prolog/reverse.pl | 4 | ||||
-rw-r--r-- | prolog/smallest.pl | 4 |
3 files changed, 10 insertions, 0 deletions
diff --git a/prolog/.gitignore b/prolog/.gitignore new file mode 100644 index 0000000..5376d5e --- /dev/null +++ b/prolog/.gitignore @@ -0,0 +1,2 @@ +*.po +*.itf diff --git a/prolog/reverse.pl b/prolog/reverse.pl new file mode 100644 index 0000000..f4aa5cd --- /dev/null +++ b/prolog/reverse.pl @@ -0,0 +1,4 @@ +reverse([], []). +reverse([H|T], L) :- + reverse(T, L2), + append(L2,H,L). diff --git a/prolog/smallest.pl b/prolog/smallest.pl new file mode 100644 index 0000000..1a8835b --- /dev/null +++ b/prolog/smallest.pl @@ -0,0 +1,4 @@ +smallest([H], H). +smallest([H|T], S) :- + smallest(T, E), + (H<E -> S is H; S is E). |