--- a/progs/defs.fun Mon Oct 14 00:02:24 2019 +0100
+++ b/progs/defs.fun Mon Oct 14 00:48:01 2019 +0100
@@ -3,19 +3,24 @@
def suc(x) = x + 1;
-def pred(x) = if x == 0 then x else x - 1;
+def pred(x) =
+ if x == 0 then x else x - 1;
-def add(x, y) = if x == 0 then y else suc(add(x - 1, y));
+def add(x, y) =
+ if x == 0 then y else suc(add(x - 1, y));
-def mult(x, y) = if x == 0 then 0 else add(y, mult(x - 1, y));
+def mult(x, y) =
+ if x == 0 then 0 else add(y, mult(x - 1, y));
-def pow(x, y) = if y == 0 then 1 else mult(x, pow(x, y - 1));
+def pow(x, y) =
+ if y == 0 then 1 else mult(x, pow(x, y - 1));
def fib(n) = if n == 0 then 0
else if n == 1 then 1
else fib(n - 1) + fib(n - 2);
-def fact(n) = if n == 0 then 1 else n * fact(n - 1);
+def fact(n) =
+ if n == 0 then 1 else n * fact(n - 1);
def ack(m, n) = if m == 0 then n + 1
else if n == 0 then ack(m - 1, 1)
@@ -27,7 +32,8 @@
def rem(x, y) = x % y; //remainder
-def gcd(a, b) = if b == 0 then a else gcd(b, a % b);
+def gcd(a, b) =
+ if b == 0 then a else gcd(b, a % b);
def is_prime_aux(n, i) =
if n % i == 0 then 0
@@ -53,24 +59,25 @@
def collatz(n) = collatz_aux(n, 1);
-def facT(n, acc) = if n == 0 then acc else facT(n - 1, n * acc);
+def facT(n, acc) =
+ if n == 0 then acc else facT(n - 1, n * acc);
//zero(3)
//suc(8)
//pred(7)
-//add(3, 4)
+//write(add(3, 4))
//mult(4,5)
//pow(2, 3)
//fib(20)
//(write(fact(5)) ; fact(6))
//(write(1) ; 2)
-ack(3, 12) // for tail-rec test
+//write(ack(3, 12)) // for tail-rec test
//stack_test(0)
//(write (div(11, 3)); rem(11, 3))
//gcd(54, 24)
//is_prime(2)
-//primes(1000000)
+primes(1000000)
//collatz(5000)
//facT(6, 1)