From baea4aa939861fd4efbc71b96f93ba890f01ac40 Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Wed, 30 Jun 2021 17:48:49 +0000 Subject: Add a standard library with the "builtins" that doesn't really need to be actual builtins --- stdlib.pl | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 stdlib.pl (limited to 'stdlib.pl') diff --git a/stdlib.pl b/stdlib.pl new file mode 100644 index 0000000..c53cf78 --- /dev/null +++ b/stdlib.pl @@ -0,0 +1,30 @@ +% Logic and control predicates +\+ Goal :- call(Goal), !, fail. +\+ Goal. + +once(Goal) :- + call(Goal), + !. + +repeat :- true ; repeat. + +% Control structures. +true. + +If -> Then :- + If, !, Then. + +If -> Then ; _ :- + If, !, Then. +_ -> _ ; Else :- + !, Else. +If ; _ :- + If. +_ ; Else :- + Else. + +% Term unification +A = A. + +A \= B :- + \+ A = B. -- cgit v1.2.3