1 Exception utilities
2 Number utilities
3 String utilities
4 Bytes utilities
5 Symbol utilities
6 List utilities
7 PLT 4x hash utilities
8 PLT 3x hash utilities
9 Contract utilities
10 File and path utilities
11 Parameter utilities
12 Syntax utilities
13 SRFI19 time utilities
14 Generators
15 Generators (short names)
16 Pipelines
17 Write-through cache
18 Yieldable procedures
19 Debugging tools
20 Profiling tools
21 Logging tools
On this page:
symbol+ false?
gensym/ interned
symbol-append
symbol-upcase
symbol-downcase
number->symbol
symbol->number
Version: 3.99.0.23

 

5 Symbol utilities

 (require (planet untyped/unlib/symbol))

Useful symbol utilities.

(symbol+false? item)  boolean?

  item : any

Returns #t if item is a symbol or #scheme[#f].

(gensym/interned [base])  symbol?

  base : (U symbol? string?) = "g"

Like gensym but returns an interned symbol that can be compared with other symbols using eq?.

Examples:

  > (define sym1 (gensym))

  > sym1

  g2419

  > (eq? sym1 (string->symbol (symbol->string sym1)))

  #f

  > (define sym2 (gensym/interned))

  > sym2

  g2420

  > (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)

  ||

(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