- Boolean
#f
> empty- (Listof 'a)
'()
- (Listof Number)
'(1)
- Number
1
- (Listof Number)
'()
> my-list- (Listof Number)
'(1 2 3)
- Number
1
- (Listof Number)
'(2 3)
- Number
2
> also-my-list- (Listof Number)
'(1 2 3)
- (Listof Number)
'(2 3)
- (Listof Number)
'(1 2 3 3 4 5)
- (Listof Number)
'(3 4 5 1 2 3)
- (Listof Number)
'(2 3 4)
- (Listof String)
'("1" "2" "3")
- (Listof Number)
'(2 4)
- (Listof Number)
'(1 3)
- Number
16
- (Listof String)
'("3" "2" "1")
- (Listof String)
'("1" "2" "3")
- (Listof Number)
'(0 10 20 30 40)
- Number
3
- Number
1
- Number
2
- Number
1
- Number
1
- Number
1
- Number
2
- Number
10.0
- Number
11.0
- Number
11.0
- Number
11
- Number
9
value
string->symbol :(String -> Symbol )
value
symbol->string :(Symbol -> String )
- Symbol
'apple
- String
"apple"
value
value
string-length :(String -> Number )
value
string-ref :(String Number -> Char )
- Boolean
#t
- String
"applebanana"
- Number
5
- String
"pp"
- Char
#\a
- Boolean
#f
value
string->list :(String -> (Listof Char ))
value
list->string :((Listof Char )-> String )
- (Listof Char)
'(#\a #\p #\p #\l #\e)
- String
"abc"
For an introduction, see the tutorial section S-Expressions.
A S-expression typically represents program text. For example, placing a ' in from of any plait expression (which is the same as wrapping it with quote ) creates an S-expression that contains the identifiers (as symbols), parenthesization (as lists), and other constants as the expression text. Various plait values, including symbols, numbers, and lists, can be coerced to and from S-expression form.
The representation of an S-expression always reuses some other plait value, so conversion to and from an S-expression is a kind cast. For example, the s-exp-symbol? function determines whether an S-expression embeds an immediate symbol; in that case, s-exp->symbol extracts the symbol, while any other value passed to s-exp->symbol raises an exception. The symbol->s-exp function wraps a symbol as an S-expression.
For interoperability of S-expressions with untyped Racket programs, see s-exp-content and s-exp .
value
s-exp-symbol? :(S-Exp -> Boolean )
value
s-exp->symbol :(S-Exp -> Symbol )
value
symbol->s-exp :(Symbol -> S-Exp )
- Boolean
#t
- Symbol
'apple
- Symbol
s-exp->symbol: not a symbol: `1
- S-Exp
`apple
value
s-exp-number? :(S-Exp -> Boolean )
value
s-exp->number :(S-Exp -> Number )
value
number->s-exp :(Number -> S-Exp )
- Boolean
#t
- Number
1
- S-Exp
`1
value
s-exp-string? :(S-Exp -> Boolean )
value
s-exp->string :(S-Exp -> String )
value
string->s-exp :(String -> S-Exp )
- Boolean
#t
- String
"apple"
- S-Exp
`"apple"
value
s-exp-boolean? :(S-Exp -> Boolean )
value
s-exp->boolean :(S-Exp -> Boolean )
value
boolean->s-exp :(Boolean -> S-Exp )
- Boolean
#t
- Boolean
#f
- S-Exp
`#f
- Boolean
#f
- Boolean
#t
value
s-exp-list? :(S-Exp -> Boolean )
value
s-exp->list :(S-Exp -> (Listof S-Exp ))
value
list->s-exp :((Listof S-Exp )-> S-Exp )
- Boolean
#t
- Boolean
#f
- (Listof S-Exp)
(list `1 `2 `3)
- S-Exp
`(1 2 3)
eval:167:0: typecheck failed: S-Exp vs. Number
sources:
list->s-exp
(list 1 2 3)
1
value
s-exp-match? :(S-Exp S-Exp -> Boolean )
For an introduction, see the tutorial section S-Expression Matching.
Compares the first S-expression, a pattern, to the second S-expression, a target.
To a first approximation, s-exp-match? is just equal? on the two S-expressions. Unlike equal? , however, certain symbols in the pattern and can match various S-expressions within the target.
For example, `NUMBER within a pattern matches any number in corresponding position within the target:
- Boolean
#t
- Boolean
#f
- Boolean
#f
The following symbol S-expressions are treated specially within the pattern:
`NUMBER — matches any number S-expression
`STRING — matches any string S-expression
`SYMBOL — matches any symbol S-expression
`ANY — matches any S-expression
`... — within a list S-expression, matches any number of repetitions of the preceding S-expression within the list; only one `... can appear as an immediate element of a pattern list, and `... is not allowed within a pattern outside of a list or as the first element of a list
Any other symbol in a pattern matches only itself in the target. For example, `+ matches only `+.
- Boolean
#t
- Boolean
#f
- Boolean
#t
- Boolean
#f
- Boolean
#t
- Boolean
#f
- Boolean
#t
- Boolean
#t
- Boolean
#f
- Boolean
#t
- Boolean
#t
- Boolean
#f
- Boolean
#t
- Boolean
#t
- Boolean
#f
- Boolean
#t
- Boolean
#t
- Boolean
#f
- Boolean
#t
- Boolean
#f
- Boolean
#t
- Boolean
#t
- Boolean
#f
- Boolean
#t
- Boolean
#t
- Boolean
#t
- Boolean
#f
For an introduction, see the tutorial section State.
value
make-vector :(Number 'a-> (Vectorof 'a))
value
vector-ref :((Vectorof 'a)Number -> 'a)
value
vector-set! :((Vectorof 'a)Number 'a-> Void )
value
vector-length :((Vectorof 'a)-> Number )
The make-vector function creates a vector of a given size and initializes all vector items to a given value. The vector-ref function accesses the value in a vector slot, and vector-set! changes the value in a slot. The vector-length function reports the number of slots in the vector.
- Number
10
- String
"apple"
- Void
- String
"banana"
- String
"apple"
For an introduction, see the tutorial section State.
The box function creates a box with an initial value for its slot, unbox accesses the current value in a box’s slot, and set-box! changes the value.
For an introduction, see the tutorial section Tuples and Options.
For an introduction, see the tutorial section Tuples and Options.
The hash-ref function works on either kind of hash table to find the value for a given key. If the hash table contains a mapping for a given key, hash-ref returns the key’s value wrapped with some . Otherwise, hash-ref returns (none ).
- (Optionof String)
(some "apple")
- (Optionof String)
(some "apple")
- (Optionof String)
(none)
Providing an immutable hash table triggers an exception.
- (Optionof String)
(some "apple")
- (Optionof String)
(none)
- Void
- Void
- (Optionof String)
(some "Apple")
- (Optionof String)
(some "coconut")
value
hash-remove :((Hashof 'a'b)'a-> (Hashof 'a'b))
- (Optionof String)
(some "apple")
- (Optionof String)
(some "Apple")
- (Optionof String)
(some "coconut")
- (Optionof String)
(none)
value
make-parameter :('a-> (Parameterof 'a))
value
parameter-ref :((Parameterof 'a)-> 'a)
value
parameter-set! :((Parameterof 'a)'a-> Void )
See also parameterize .
- Boolean
#t
- Boolean
#t
value
The current continuation is itself represented as a function. Applying a continuation function discards the current continuation and replaces it with the called one, supplying the given value to that continuation.
value
s-exp-content :no type
value
s-exp :no type
value
tuple-content :no type
value
tuple :no type