str
From the SETL Wiki
| str | |
|---|---|
| Category | general |
| Syntax | prefix (function in SETL2) |
| Compatibility | |
| CIMS SETL | yes |
| SETL-S | yes |
| SETL2 | yes (redefinable) |
| GNU SETL | yes |
Contents |
Purpose
Convert any value to a string
Synopsis
str x
Description
Converts any SETL value to a string. The string representation is both human- and machine-readable. The method of conversion depends on the type of the object.
unstr is approximately the inverse of this function, though it cannot recreate atoms or procedure references and will accept some strings that str cannot generate, e.g. with extra spaces or redundant quotes inserted.
Examples
| x | str x | str(x) (SETL2) |
|---|---|---|
| om | * | <om> |
| 42 | 42 | 42 |
| 'a' | a | "a" |
| '!@#' | '!@#' | "!@#" |
| {1, 1.0, 2} | {1 1 2} (see note 1) | {1, 1.0000000000, 2} |
| ['a', '!@#', 'b', 'c d'] | [a '!@#' b 'c d'] | ["a", "!@#", "b", "c d"] |
| newat() | #1 | <atom 1> |
Notes
- GNU SETL's implementation of str sometimes renders real numbers the same way as integers, if they are sufficiently close to the corresponding integer value. This is not usually a problem since wherever the two types are mixed they are usually interchangeable.


