diff options
author | ubq323 <ubq323@ubq323.website> | 2024-07-03 11:52:13 +0100 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2024-07-03 11:52:13 +0100 |
commit | 9f4e10da9df486b4c048ec2fedbe28491059b739 (patch) | |
tree | f963a20550c8455e0b0d53b7c7067b6fa4ea6782 /tests | |
parent | 70c782292f48358fc4d3ac3874ac1951b405de48 (diff) |
add defn form
Diffstat (limited to 'tests')
-rw-r--r-- | tests/defn.bth | 2 | ||||
-rw-r--r-- | tests/sumrec_local.bth | 8 | ||||
-rw-r--r-- | tests/sumrec_local.out | 2 |
3 files changed, 12 insertions, 0 deletions
diff --git a/tests/defn.bth b/tests/defn.bth new file mode 100644 index 0000000..81fcada --- /dev/null +++ b/tests/defn.bth @@ -0,0 +1,2 @@ +(defn (f x) (* x x)) +(say (f 12)) diff --git a/tests/sumrec_local.bth b/tests/sumrec_local.bth new file mode 100644 index 0000000..b40418b --- /dev/null +++ b/tests/sumrec_local.bth @@ -0,0 +1,8 @@ +(defn (f' x acc) + (if (< x 1) + acc + (f' (- x 1) (+ acc x)))) +(set _global_f' f') +(defn (f x) (_global_f' x 0)) +(say (f 10)) +(say (f 1000)) diff --git a/tests/sumrec_local.out b/tests/sumrec_local.out new file mode 100644 index 0000000..2a5dbfe --- /dev/null +++ b/tests/sumrec_local.out @@ -0,0 +1,2 @@ +55 +500500 |