aboutsummaryrefslogtreecommitdiff
path: root/tests/lang/eval-okay-arithmetic.nix
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-09-22 15:29:21 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-09-22 15:29:21 +0000
commit2ab4bc44c780d2e28647f7559664675b756f38b9 (patch)
tree39ecb0e001cf6c031e15b0246559b3f8f7a06ed9 /tests/lang/eval-okay-arithmetic.nix
parentd315210612a8d5eb52654407903544b72222130b (diff)
* Builtin function `add' to add integers.
* Put common test functions in tests/lang/lib.nix.
Diffstat (limited to 'tests/lang/eval-okay-arithmetic.nix')
-rw-r--r--tests/lang/eval-okay-arithmetic.nix18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/lang/eval-okay-arithmetic.nix b/tests/lang/eval-okay-arithmetic.nix
new file mode 100644
index 000000000..735f01cf4
--- /dev/null
+++ b/tests/lang/eval-okay-arithmetic.nix
@@ -0,0 +1,18 @@
+with import ./lib.nix;
+
+let {
+
+ range = first: last: [first] ++ (if first == last then [] else range (builtins.add first 1) last);
+
+ /* Supposedly tail recursive version:
+
+ range_ = accum: first: last:
+ if first == last then ([first] ++ accum)
+ else range_ ([first] ++ accum) (builtins.add first 1) last;
+
+ range = range_ [];
+ */
+
+ body = sum (range 1 50);
+
+}