This commit is contained in:
2020-11-14 15:27:09 -07:00
parent 2383d8c8c0
commit 27db700268
3 changed files with 12 additions and 0 deletions

View File

@@ -17,6 +17,11 @@ class SpecialForms {
expr: EBlock([for (bodyExp in args) convert(bodyExp)])
};
map["nth"] = (args:Array<ReaderExp>, convert:ExprConversion) -> {
pos: Context.currentPos(),
expr: EArray(convert(args[0]), convert(args[1]))
};
return map;
}
}

View File

@@ -43,6 +43,10 @@ class BasicTestCase extends Test {
Assert.equals(1, arr[-3]);
}
function testArrayAccess() {
Assert.equals(3, BasicTestCase.myArrayLast);
}
function testVariadicAdd() {
Assert.equals(6, BasicTestCase.mySum);
}

View File

@@ -21,6 +21,9 @@
// [...] returns a Kiss array (they have special features and convert implicitly)
(defvar myArray [1 2 3])
// Array access is via nth
(defvar myArrayLast (nth myArray -1))
// Variadic math uses haxe's Lambda.fold under the hood
(defvar mySum (+ 1 2 3))