nth and dictGet in KissInterp2
Some checks failed
CI / test (push) Failing after 15s
CI / test-core (14, ubuntu-latest, 3.x, py) (push) Failing after 44s
CI / test-core (14, ubuntu-latest, 3.x, interp) (push) Failing after 46s
CI / test-core (14, ubuntu-latest, 3.x, js) (push) Failing after 50s
CI / test-core (14, ubuntu-latest, 3.x, nodejs) (push) Failing after 56s
CI / test-core (14, ubuntu-latest, 3.x, cpp) (push) Failing after 51s

This commit is contained in:
2025-11-09 15:54:57 -06:00
parent 292d6ca03b
commit 2678a2f217
3 changed files with 22 additions and 0 deletions

View File

@@ -73,6 +73,20 @@
// in the interp variables. That might be nice.
(_evalAllCC args ->vals
(cc (Type.createInstance (first vals) (rest vals))))
=>"nth"
->[args cc]
(evalCC (first args)
->container
(evalCC (second args)
->index
(cc (nth container index))))
=>"dictGet"
->[args cc]
(evalCC (first args)
->container
(evalCC (second args)
->key
(cc (container.get key))))
])
(method :ReaderExp read [:Dynamic input]

View File

@@ -34,4 +34,7 @@ class KissInterp2TestCase extends Test {
function testLet() {
_testLet();
}
function testNth() {
_testNth();
}
}

View File

@@ -39,3 +39,8 @@
(function _testLet []
(let [interp (new Interp)]
(assertEval 5 "(let [a 2 b 3] (+ a b))")))
(function _testNth []
(let [interp (new Interp)]
(assertEval 2 "(nth [1 2 3] 1)")
(assertEval 9 #"(dictGet [=>"a" 2 =>"b" 9 =>"c" 3] "b")"#)))