add join function to stdlib

Signed-off-by: Ava Affine <ava@sunnypup.io>
This commit is contained in:
Ava Apples Affine 2024-06-01 08:55:53 -07:00
parent 386d0900a9
commit 3d0d8d8215
4 changed files with 18 additions and 2 deletions

View file

@ -146,3 +146,13 @@ adds a directory to PATH'
(rem (cdr path-iter)))
(echo pat)
(set (q path-iter) (pop rem))))))
(def join
'concatenates list elements into a string, while
interspersing a provided delimiter in between elements'
(list delim)
(reduce (lambda (res elem)
(if (eq? (strlen res) 0)
(string elem)
(concat res delim elem)))
list))