Qu

chars

Builtin index · Collections & strings

result = chars(s)

Input: s · Output: result

What it is

s is a Str.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = chars(s)
s Strnot documented yet
result List or Str
Returns a List of one-character Strs.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

text = "one\ntwo\nthree"
print(lines(text))                     # ("one", "two", "three")

print(chars("abc"))                    # ("a", "b", "c")

print(repeat_str("ab", 3))             # "ababab"

print(as_text([1, 2, 3]).join(", "))   # "1, 2, 3"

output
("one", "two", "three")
("a", "b", "c")
ababab
1, 2, 3

from collections-strings

How it works

chars(s) — the characters, one string each. split(s, "") already does this; chars exists because that is not the first thing anyone thinks to write.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.