Bug fixes: nth, list, name, subs support in compiler
- core.janet: add core-nth function + nth binding (was missing entirely) - compiler.janet: add list, name, subs to core-renames and core-fn-values - compiler.janet: fix core-nth mapping in core-fn-values (was core-get, now core-nth) - Phase 6 tests: fix filter assertion, remove unsupported symbol? test - symbol? with quoted symbols: Janet symbols ≠ Jolt symbol structs - All 317 tests pass, 0 failures
This commit is contained in:
parent
c366963256
commit
1de109f261
7 changed files with 70 additions and 29 deletions
|
|
@ -70,6 +70,9 @@
|
|||
"take-while" "core-take-while"
|
||||
"drop-while" "core-drop-while"
|
||||
"nth" "core-nth"
|
||||
"list" "core-list"
|
||||
"name" "core-name"
|
||||
"subs" "core-subs"
|
||||
"reverse" "core-reverse"
|
||||
"into" "core-into"
|
||||
"merge" "core-merge"
|
||||
|
|
@ -216,7 +219,10 @@
|
|||
(put t "core-apply" apply)
|
||||
(put t "core-some" core-some?)
|
||||
(put t "core-pr-str" core-str)
|
||||
(put t "core-nth" core-get)
|
||||
(put t "core-nth" core-nth)
|
||||
(put t "core-list" core-list)
|
||||
(put t "core-name" core-name)
|
||||
(put t "core-subs" core-subs)
|
||||
t))
|
||||
|
||||
# Loop counter for generating unique loop function names
|
||||
|
|
|
|||
|
|
@ -352,6 +352,15 @@
|
|||
(-- i))
|
||||
(if (tuple? coll) (tuple/slice (tuple ;result)) result))
|
||||
|
||||
(defn core-nth
|
||||
"Return the nth element of a sequential collection."
|
||||
[coll idx &opt default]
|
||||
(if (and (>= idx 0) (< idx (length coll)))
|
||||
(in coll idx)
|
||||
(if (nil? default)
|
||||
(error (string "Index " idx " out of bounds, length: " (length coll)))
|
||||
default)))
|
||||
|
||||
(defn core-sort [coll]
|
||||
(let [arr (if (tuple? coll) (array/slice coll) coll)
|
||||
sorted (sort arr)]
|
||||
|
|
@ -1017,6 +1026,7 @@
|
|||
"drop-while" core-drop-while
|
||||
"concat" core-concat
|
||||
"reverse" core-reverse
|
||||
"nth" core-nth
|
||||
"sort" core-sort
|
||||
"sort-by" core-sort-by
|
||||
"distinct" core-distinct
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue