5 Symbol utilities
Useful symbol utilities.
(symbol+false? item) → boolean? |
item : any |
Returns #t if item is a symbol or #scheme[#f].
(gensym/interned [base]) → symbol? |
Like gensym but returns an interned symbol that can be compared with other symbols using eq?.
Examples: |
> sym1 |
g404 |
> (eq? sym1 (string->symbol (symbol->string sym1))) |
#f |
> (define sym2 (gensym/interned)) |
> sym2 |
g405 |
> (eq? sym2 (string->symbol (symbol->string sym2))) |
#t |
(symbol-append sym ) → symbol? |
sym : symbol? |
The symbol equivalent of string-append. Returns an interned symbol.
Examples: |
> (symbol-append 'abc 'def 'ghi) |
abcdefghi |
> (symbol-append 'abc) |
abc |
> (symbol-append) |
|| |
sym : symbol? |
The symbol equivalent of string-length.
Examples: |
> (symbol-length 'AbC123) |
6 |
(symbol-upcase sym) → symbol? |
sym : symbol? |
The symbol equivalent of string-upcase. Returns an interned symbol.
Examples: |
> (symbol-upcase 'AbC123) |
ABC123 |
(symbol-downcase sym) → symbol? |
sym : symbol? |
The symbol equivalent of string-downcase. Returns an interned symbol.
Examples: |
> (symbol-downcase 'AbC123) |
abc123 |
(number->symbol num) → symbol? |
num : number? |
The symbol equivalent of number->string. Returns an interned symbol.
Examples: |
> (number->symbol 123) |
|123| |
> (number->symbol (/ 1 3)) |
|1/3| |
(symbol->number sym) → number? |
sym : symbol? |
The symbol equivalent of string->number. Returns #f if sym has no numeric equivalent.
Examples: |
> (symbol->number '|123|) |
123 |
> (symbol->number 'abc) |
#f |
(number+false->symbol+false num) → (U symbol? #f) |
num : (U number? #f) |
A version of number->symbol that accepts and passes through #f.
(symbol+false->number+false sym) → (U number? #f) |
sym : (U symbol? #f) |
A version of symbol->number that accepts and passes through #f.
(string+false->symbol+false str) → (U symbol? #f) |
str : (U string? #f) |
A version of string->symbol that accepts and passes through #f.
(symbol+false->string+false sym) → (U string? #f) |
sym : (U symbol? #f) |
A version of symbol->string that accepts and passes through #f.