Preview
Sign inSign up
Forms and builtinsStrings and symbols

Forms and builtins

Strings and symbols

12 builtins. Every example below ran on the evaluator, and the result shown is what it returned.

string?

arity 1
(string? x)

Is the argument a string?

(list (string? "a") (string? 'a))

=>(#t #f)

symbol?

arity 1
(symbol? x)

Is the argument a symbol?

(list (symbol? 'a) (symbol? "a"))

=>(#t #f)

(string-append s ...)

Joins strings.

(string-append "foo" "bar")

=>"foobar"

(string-length s)

Number of characters (codepoints).

(string-length "héllo")

=>5

substring

arity 2-3
(substring s start [end])

(substring s start end): characters from start up to, not including, end.

(substring "hello world" 6 11)

=>"world"

string=?

arity 1+
(string=? s t ...)

Are the strings equal?

(string=? "abc" "abc")

=>#t

string<?

arity 1+
(string<? s t ...)

Are the strings in increasing order?

(string<? "apple" "banana")

=>#t

string>?

arity 1+
(string>? s t ...)

Are the strings in decreasing order?

(string>? "apple" "banana")

=>#f

(string-upcase s)

Upper-cased copy.

(string-upcase "shout")

=>"SHOUT"

(string-downcase s)

Lower-cased copy.

(string-downcase "QUIET")

=>"quiet"

(string->symbol s)

The symbol with this name.

(string->symbol "hello")

=>hello

(symbol->string sym)

The symbol's name.

(symbol->string 'hello)

=>"hello"

esc