diff --git a/core/String.carp b/core/String.carp index e4e02eea..d82917b4 100644 --- a/core/String.carp +++ b/core/String.carp @@ -515,6 +515,11 @@ (if (String.empty? s) '() (cons (String.head s) (String.to-list (String.tail s))))) + + (doc to-array + "Converts a string to an array of strings of each of its characters.") + (defndynamic to-array [s] + (cdr (String.split-on "" s))) ) ) diff --git a/test/macros.carp b/test/macros.carp index e4466ad6..8b09de41 100644 --- a/test/macros.carp +++ b/test/macros.carp @@ -387,6 +387,10 @@ '("h" "e" "l" "l" "o") (String.to-list "hello") "Dynamic.String.to-list works as expected") + (assert-dynamic-equal test + '["h" "e" "l" "l" "o"] + (String.to-array "hello") + "Dynamic.String.to-array works as expected") (assert-equal test 2 (let-do [src 1 dst 0]