Skip to content

Take

Name Mandatory Description Default Type
⬅️ Input The sequence or table from which elements or values will be extracted. Int2Int3Int4Int8Int16Float2Float3Float4BytesColorString[Any]{Any}
Output ➡️ The extracted elements from a sequence or values from a table. If the key cannot be established to exist at compose time, the output will be of type Any. Any
Indices/Keys No One or more indices or keys to extract from a sequence or table. none AnyVar(Any)

Extracts one or more elements from a sequence or values from a table using the provided indices or keys. This operation is non-destructive and does not modify the target sequence or table. If the key cannot be established to exist at compose time, the output will be of type Any.

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
; Take on sequences
[10 20 30 40] | Take(1) | Log
Assert.Is(20 Break: true)

[10 20 30 40] | Take([1 2]) | Log
Assert.Is([20 30] Break: true)

; Take on tables
{Hello: 10 World: 20} | Take("Hello") | Log
Assert.Is(10 Break: true)

{Hello: 10 World: 20} | Take(["World" "Hello"]) | Log
Assert.Is([20 10] Break: true)

{Hello: 10 World: 20} | Take("Universe") | Log
Assert.Is(none Break: true)

{abc: 10 def: 20} | Take("def") | Log
Assert.Is(20 Break: true)

; Take using a variable as index
1 = index
[1 2 3 4] | Take(index) | Log
Assert.Is(2 Break: true)

"Hello" = key
{Hello: 10 World: 20} | Take(key) | Log
Assert.Is(10 Break: true)

[info] [sample-wire] 20
[info] [sample-wire] [20 30]
[info] [sample-wire] 10
[info] [sample-wire] [20 10]
[info] [sample-wire] none
[info] [sample-wire] 20
[info] [sample-wire] 2
[info] [sample-wire] 10