blob: d3074c9148a4a0a0b8c5a6a6d454f8efa81920a3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
Structs are composite types that contain values of different types associated
with a set of string keys. The set of keys and their corresponding value types
is fixed at *runtime*.
Struct values can be created using the the [`(struct …)`][:struct:] builtin,
which uses [Pure Op](04-2_pure-operators.html) semantics to construct a struct
from its parameters. The keys have to be constants.
(trace (struct "a" 1 "b" 'hello world'))
```output
<{a: num b: str}= {a: 1 b: "hello world"}>
```
The type notation `{a: num b: str}` designates a struct type with the key `a`
mapping to a value of type `num` and the key `b` mapping to a value of type
`str` respectively, whereas the value notation `{a: 1 b: "hello world"}` shows
the struct contents.
The [struct-][:struct-/:] module provides *Op*s for working with arrays.
|