From 4fb3fa2758fd4db2bef1efc7ae531e0dadaf4ffa Mon Sep 17 00:00:00 2001 From: Guillermo Ramos Date: Thu, 3 May 2012 14:12:06 +0200 Subject: [Prolog] Día 2 --- prolog/.gitignore | 2 ++ prolog/reverse.pl | 4 ++++ prolog/smallest.pl | 4 ++++ 3 files changed, 10 insertions(+) create mode 100644 prolog/.gitignore create mode 100644 prolog/reverse.pl create mode 100644 prolog/smallest.pl 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 S is H; S is E). -- cgit v1.2.3