(rest [list])
This commit is contained in:
@@ -55,7 +55,10 @@ class SpecialForms {
|
|||||||
makeQuickNth(9, "tenth");
|
makeQuickNth(9, "tenth");
|
||||||
makeQuickNth(-1, "last");
|
makeQuickNth(-1, "last");
|
||||||
|
|
||||||
// TODO rest
|
map["rest"] = (wholeExp:ReaderExp, args:Array<ReaderExp>, k:KissState) -> {
|
||||||
|
wholeExp.checkNumArgs(1, 1, '(rest [list])');
|
||||||
|
macro ${k.convert(args[0])}.slice(1);
|
||||||
|
};
|
||||||
|
|
||||||
// Declare anonymous objects
|
// Declare anonymous objects
|
||||||
map["object"] = (wholeExp:ReaderExp, args:Array<ReaderExp>, k:KissState) -> {
|
map["object"] = (wholeExp:ReaderExp, args:Array<ReaderExp>, k:KissState) -> {
|
||||||
|
@@ -250,6 +250,10 @@ class BasicTestCase extends Test {
|
|||||||
function testRange() {
|
function testRange() {
|
||||||
_testRange();
|
_testRange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testRest() {
|
||||||
|
_testRest();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class BasicObject {
|
class BasicObject {
|
||||||
|
@@ -367,4 +367,7 @@
|
|||||||
(set myList (for i (range 7 17 2) i))
|
(set myList (for i (range 7 17 2) i))
|
||||||
(Assert.equals 7 (first myList))
|
(Assert.equals 7 (first myList))
|
||||||
(Assert.equals 9 (second myList))
|
(Assert.equals 9 (second myList))
|
||||||
(Assert.equals 15 (last myList)))
|
(Assert.equals 15 (last myList)))
|
||||||
|
|
||||||
|
(defun _testRest []
|
||||||
|
(Assert.equals (.toString [2 3 4]) (.toString (rest [1 2 3 4]))))
|
Reference in New Issue
Block a user