Skip to content

Table

Name - Description Default Type
<input> Any input is ignored. Any
<output> The input to this shard is passed through as its output. Any
Name The name of the variable. "" String&Any
Key The key of the value to write in the table (parameter applicable only if the target variable is a table). None String&String
Global If the variable is available to all of the wires in the same mesh. false Bool
Type The table type to forward declare. None Type

Creates an empty table.

Details

Table creates an empty table with or without a specified key (via the :Key parameter). The created table name is defined in the :Name parameter.

Whether the created table variable has a global scope (available to all wires on the mesh) or a local scope (available only to the wire its defined in) can be controlled via the :Global parameter (true for global scope, false for local scope; default is false).

In addition to the key and the scope, this shard can also define the table's inner data types via the :Types parameter. More than one data type may be set.

Any input to this shard is ignored and instead passed through as its output.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
;; without key, without types, local scope, using `Push` (puts sequence values)
;; (Table :Name .tableA)
;; .tableA (Log)         ;; created a table => {A: []}
1 (Push .tableA "A")
.tableA (Log)         ;; updated table => {A: [1]}
2 (Push .tableA "A")
.tableA (Log)         ;; updated table => {A: [1, 2]}

;; with key, single type, global scope, using `Set`
(Table .tableB :Key "A" :Global true :Type (type {:A Float}))
.tableB (Log)         ;; created a table => {A: {}}
10.2 (Set .tableB "A")
.tableB (Log)         ;; updated table => {A: 10.2}
20.1 (Set .tableB "A")
.tableB (Log)         ;; updated table => {A: 20.1}

;; with key, multiple types, local scope, using `Set`
(Table .tableC :Key "A" :Type (type {:A Float :B Int}))
.tableC (Log)         ;; created a table => {A: {}}
10.3 (Set .tableC "A")
.tableC (Log)         ;; updated table => {A: 10.3}
20 (Set .tableC "B")
.tableC (Log)         ;; updated table => {B: 20, A: 10.3}

;; with key, single type, local scope, using `Push` (puts sequence values)
;; (Table .tableD :Key "A" :Types Type.Int)
;; .tableD (Log)         ;; created a table => {A: []}
10 (Push .tableD "A")
.tableD (Log)         ;; updated table => {A: [10]}
20 (Push .tableD "A")
.tableD (Log)         ;; updated table => {A: [10, 20]}
[info] [shards/General/Table/Table.edn] {A: [1]}
[info] [shards/General/Table/Table.edn] {A: [1 2]}
[info] [shards/General/Table/Table.edn] {A: {}}
[info] [shards/General/Table/Table.edn] {A: 10.2}
[info] [shards/General/Table/Table.edn] {A: 20.1}
[info] [shards/General/Table/Table.edn] {A: {}}
[info] [shards/General/Table/Table.edn] {A: 10.3}
[info] [shards/General/Table/Table.edn] {A: 10.3 B: 20}
[info] [shards/General/Table/Table.edn] {A: [10]}
[info] [shards/General/Table/Table.edn] {A: [10 20]}