Skip to content

Sequence

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 read/write from/in the table (parameter applicable only if the target variable is or will become a table). None String&String
Global If the variable is or should be available to all of the wires in the same mesh. false Bool
Clear If we should clear this sequence at every wire iteration; works only if this is the first push; default: true. true Bool
Types The sequence inner types to forward declare. Type.Any Type[ Type ][ Type [ Type ] Self ]

Creates an empty sequence (or table if a key is passed).

Details

Sequence creates an empty sequence when the :Key parameter is not set. If a key is passed via this parameter Sequence creates an empty table instead (behaving like the Table shard). The created sequence name is defined in the :Name parameter.

This shard can control the scope of the created sequence variable. A true value for the :Global parameter makes the scope of the sequence global (available to all wires on the mesh), and a false value makes the scope local (available only to the wire its defined in).

By default a sequence created with this shard would be cleared (emptied) every time the wire is executed (since :Clear is true by default). To retain the sequence values across wire iterations set the :Clear parameter to false.

This shard can also define the sequence'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.

See also

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, :Clear true, using `Push`
(Sequence :Name .seqA)
.seqA (Log)             ;; created an empty sequence => []
1 (Push .seqA)
.seqA (Log)             ;; updated sequence => [1]
2 (Push .seqA) 
.seqA (Log)             ;; updated sequence => [1, 2]

;; with key (becomes table), single type, global scope, :Clear true, using `Set`
(Sequence .seqB :Key "A" :Global true :Types Type.Float)
.seqB  (Log)            ;; created an empty table => {A: []}
10.2 (Set .seqB  "A")
.seqB  (Log)            ;; updated table => {A: 10.2}
20.1 (Set .seqB  "A") 
.seqB  (Log)            ;; updated table => {A: 20.1}    

;; without key, multiple types, local scope, :Clear false, using `Push`
(Sequence .seqC :Types [Type.Float Type.Int] :Clear false)
.seqC (Log)             ;; created an empty sequence => []
10.3 (Push .seqC)
.seqC (Log)             ;; updated sequence => [10.3]
20 (Push .seqC) 
.seqC(Log)              ;; updated sequence => [10.3, 20]

;; with key (becomes table), single type, local scope, :Clear true, using `Push`
;; (Sequence .seqD :Key "A" :Types Type.Int)
;; .seqD (Log)             ;; created an empty table => {A: []}
10 (Push .seqD "A")
.seqD(Log)              ;; updated table => {A: [10]}
20 (Push .seqD"A") 
.seqD (Log)             ;; updated table => {A: [10, 20]}
[info] [shards/General/Sequence/Sequence.edn] []
[info] [shards/General/Sequence/Sequence.edn] [1]
[info] [shards/General/Sequence/Sequence.edn] [1, 2]
[info] [shards/General/Sequence/Sequence.edn] {A: []}
[info] [shards/General/Sequence/Sequence.edn] {A: 10.2}
[info] [shards/General/Sequence/Sequence.edn] {A: 20.1}
[info] [shards/General/Sequence/Sequence.edn] []
[info] [shards/General/Sequence/Sequence.edn] [10.3]
[info] [shards/General/Sequence/Sequence.edn] [10.3, 20]
[info] [shards/General/Sequence/Sequence.edn] {A: [10]}
[info] [shards/General/Sequence/Sequence.edn] {A: [10, 20]}