28 Symbol utilities
(require (planet untyped/unlib/symbol)) |
Useful symbol utilities.
Like gensym but returns an interned symbol that can be compared with other symbols using eq?.
Examples: |
> (define sym1 (gensym)) |
> sym1 |
g1162 |
> (eq? sym1 (string->symbol (symbol->string sym1))) |
#f |
> (define sym2 (gensym/interned)) |
> sym2 |
g1163 |
> (eq? sym2 (string->symbol (symbol->string sym2))) |
#t |
The symbol equivalent of string-append. Returns an interned symbol.
Examples: |
> (symbol-append 'abc 'def 'ghi) |
abcdefghi |
> (symbol-append 'abc) |
abc |
> (symbol-append) |
|| |
Example: |
> (symbol-length 'AbC123) |
6 |
The symbol equivalent of string-upcase. Returns an interned symbol.
Example: |
> (symbol-upcase 'AbC123) |
ABC123 |
The symbol equivalent of string-downcase. Returns an interned symbol.
Example: |
> (symbol-downcase 'AbC123) |
abc123 |
The symbol equivalent of number->string. Returns an interned symbol.
Examples: |
> (number->symbol 123) |
|123| |
> (number->symbol (/ 1 3)) |
|1/3| |
The symbol equivalent of string->number. Returns #f if sym has no numeric equivalent.
Examples: |
> (symbol->number '|123|) |
123 |
> (symbol->number 'abc) |
#f |
A version of number->symbol that accepts and passes through #f.
A version of symbol->number that accepts and passes through #f.
A version of string->symbol that accepts and passes through #f.