as_text
Builtin index · Collections & strings
result = as_text(v)
Input: v · Output: result
What it is
v is a Vec, List, or Signal.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = as_text(v) | v Vec, List, or Signalnot documented yet | Str —each element formatted the way print would | Returns a List of Str (each element formatted the way print would), so [1, 2, 3].as_text().join(", ") works. str renders the whole value as one string in one shot — a different question. |
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, 3from collections-strings
How it works
as_text(v) — the elements as strings, so a numeric vector can be joined: [1, 2, 3].as_text().join(", "). str renders the whole value as one string, which is a different question.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.