diff options
Diffstat (limited to '')
-rw-r--r-- | test/ack.t | 15 | ||||
-rw-r--r-- | test/fib.t (renamed from test/test1.t) | 4 | ||||
-rw-r--r-- | test/ggt.t (renamed from test/test5.t) | 5 | ||||
-rw-r--r-- | test/test2.t | 9 | ||||
-rw-r--r-- | test/test3.t | 10 | ||||
-rw-r--r-- | test/test4.t | 9 | ||||
-rw-r--r-- | test/times2.t | 7 |
7 files changed, 28 insertions, 31 deletions
diff --git a/test/ack.t b/test/ack.t new file mode 100644 index 0000000..f9d892c --- /dev/null +++ b/test/ack.t @@ -0,0 +1,15 @@ +fun main[n,m] + print call ack[n,m] +end + +fun ack[n,m] + if n == 0 + @m + 1 + else + if m == 0 + @call ack[n-1, 1] + else + @call ack[n-1, call ack[n, m-1]] + end + end +end diff --git a/test/test1.t b/test/fib.t index 12580bd..2a24f6d 100644 --- a/test/test1.t +++ b/test/fib.t @@ -6,10 +6,10 @@ fun fib[a] end # main function -fun main[] +fun main[num] sum = 0 i = 0 - while (i < 10) + while (i < num) sum = sum + call fib[i] i = i + 1 end diff --git a/test/test5.t b/test/ggt.t index c6e786d..2eeb07a 100644 --- a/test/test5.t +++ b/test/ggt.t @@ -3,7 +3,10 @@ fun main[] print x y = call ggt2[30,40] print y - @x == y + if x == y + @0 + end + @1 end fun ggt1[x,y] diff --git a/test/test2.t b/test/test2.t deleted file mode 100644 index 8a19e95..0000000 --- a/test/test2.t +++ /dev/null @@ -1,9 +0,0 @@ -fun main[] - sum = 0 - i = (sum + 10) * 5 - while (i + 3 < 10) - sum = sum + call fib[i] - i = i + 1 - end - @sum -end diff --git a/test/test3.t b/test/test3.t deleted file mode 100644 index 682f707..0000000 --- a/test/test3.t +++ /dev/null @@ -1,10 +0,0 @@ -fun main[] - a = 3 - b = 5 - if (a > b) - c = 1 - else - c = 0 - end - @c -end diff --git a/test/test4.t b/test/test4.t deleted file mode 100644 index 7cb19ff..0000000 --- a/test/test4.t +++ /dev/null @@ -1,9 +0,0 @@ -fun times2[n] - @n*2 -end - -fun main[] - n = 10 + 5 - res = call times2[n] - @res -end diff --git a/test/times2.t b/test/times2.t new file mode 100644 index 0000000..723bea6 --- /dev/null +++ b/test/times2.t @@ -0,0 +1,7 @@ +fun times2[n] + @n*2 +end + +fun main[n] + @call times2[n] +end |