(collect) macro

This commit is contained in:
2021-04-25 14:30:37 -06:00
parent 5a05aec560
commit 0e98e72245
3 changed files with 14 additions and 0 deletions

View File

@@ -51,6 +51,10 @@ class BasicTestCase extends Test {
Assert.equals(3, BasicTestCase.myArrayLast);
}
function testCollect() {
_testCollect();
}
function testVariadicAdd() {
Assert.equals(6, BasicTestCase.mySum);
}

View File

@@ -27,6 +27,10 @@
// Array access is via nth
(defvar myArrayLast (nth myArray -1))
// (collect) turns iterators to arrays
(defun _testCollect []
(Assert.equals "[0,1,2]" (Std.string (collect (range 3)))))
// Variadic math uses haxe's Lambda.fold under the hood
(defvar mySum (+ 1 2 3))