From 45c3f81891837820aea7c3dbd45e3bae25fc4c22 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Sat, 4 Mar 2023 22:46:07 +0100 Subject: small things --- inst/prelude.pl | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'inst') diff --git a/inst/prelude.pl b/inst/prelude.pl index cc0c940..34e7853 100644 --- a/inst/prelude.pl +++ b/inst/prelude.pl @@ -45,17 +45,8 @@ Ax > Bx :- A is Ax, B is Bx, int2p_lt(B,A). Ax >= Bx :- A is Ax, B is Bx, int2p_leq(B,A). zero(Ax) :- A is Ax, int1p_zero(A). -gcd(X,Y,R) :- writeln(a), fail. -gcd(X,Y,R) :- writeln(b), zero(Y), !, R=X. -gcd(X,Y,R) :- writeln(c), X1 is X mod Y, gcd(Y,X1,R). -gcd(X,Y,R) :- writeln(a), Y > X, writeln(wat), !, gcd(Y,X,R). -gcd(X,Y,R) :- writeln(b), zero(Y), !, R=X. -gcd(X,Y,R) :- writeln(c), X1 is X mod Y, gcd(Y,X1,R). +gcd(X,Y,R) :- Y > X, !, gcd(Y,X,R). +gcd(X,Y,R) :- zero(Y), !, R=X. +gcd(X,Y,R) :- X1 is X mod Y, gcd(Y,X1,R). -test(X) :- writeln(there), zero(X), fail. -test(X) :- writeln(here). - -test :- writeln(a), a=a, !, fail. -test :- writeln(b). - -xxx :- test. +lcm(X,Y,R) :- gcd(X,Y,GCD), R is X*(Y/GCD). -- cgit v1.2.3