feat: add String.to-list (#1185)

This commit is contained in:
Veit Heller 2021-03-15 16:22:10 +01:00 committed by GitHub
parent d8d3669a16
commit 64b0dc4922
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -486,3 +486,15 @@
(defmacro str* [:rest forms]
`(copy %(build-str* forms)))
(defmodule Dynamic
(defmodule String
(defndynamic empty? [s]
(= (String.length s) 0))
(defndynamic to-list [s]
(if (String.empty? s)
'()
(cons (String.head s) (String.to-list (String.tail s)))))
)
)

View File

@ -428,4 +428,8 @@
3
(test-round 2.51)
"Dynamic.round works as expected II")
(assert-dynamic-equal test
'("h" "e" "l" "l" "o")
(String.to-list "hello")
"Dynamic.String.to-list works as expected")
)