1
0
mirror of https://github.com/janet-lang/janet synced 2025-09-10 06:46:08 +00:00

Add array/join and tuple/join

Utilities for combining indexed types more efficiently. `array/join`
also solves some interface issues with array/concat
This commit is contained in:
Calvin Rose
2024-08-10 15:16:28 -05:00
parent ce36c4c0d6
commit ab70524d85
5 changed files with 96 additions and 0 deletions

View File

@@ -76,6 +76,16 @@
(array/trim a)
(array/ensure @[1 1] 6 2)
# array/join
(assert (deep= @[1 2 3] (array/join @[] [1] [2] [3])) "array/join 1")
(assert (deep= @[] (array/join @[])) "array/join 2")
(assert (deep= @[1 :a :b :c] (array/join @[1] @[:a :b] [] [:c])) "array/join 3")
(assert (deep= @[:x :y :z "abc123" "def456"] (array/join @[:x :y :z] ["abc123" "def456"])) "array/join 4")
(assert-error "array/join error 1" (array/join))
(assert-error "array/join error 2" (array/join []))
(assert-error "array/join error 3" (array/join [] "abc123"))
(assert-error "array/join error 4" (array/join @[] "abc123"))
(assert-error "array/join error 5" (array/join @[] "abc123"))
(end-suite)