@@ -28,7 +28,7 @@ For example:
2828let colors = [yellow green]
2929let colors = ($colors | prepend red)
3030let colors = ($colors | append purple)
31- echo $colors # [red yellow green purple]
31+ $colors # [red yellow green purple]
3232```
3333
3434## Iterating over lists
@@ -51,7 +51,7 @@ The following example gets all the colors whose names end in "e".
5151
5252` ` ` bash
5353let colors = [red orange yellow green blue purple]
54- echo $colors | where ($it | str ends-with ' e' )
54+ $colors | where ($it | str ends-with ' e' )
5555` ` `
5656
5757In this example, we keep only values higher than ` 7` .
@@ -61,7 +61,7 @@ In this example, we keep only values higher than `7`.
6161# This outputs the list [orange blue purple].
6262
6363let scores = [7 10 8 6 7]
64- echo $scores | where $it > 7 # [10 8]
64+ $scores | where $it > 7 # [10 8]
6565` ` `
6666
6767The [` reduce` ](commands/reduce.md) command computes a single value from a list.
@@ -78,7 +78,7 @@ echo "total =" ($scores | math sum) # easier approach, same result
7878
7979echo " product =" ($scores | reduce --fold 1 { | it, acc| $acc * $it }) # 96
8080
81- echo $scores | reduce -n { | it, acc| $acc .item + $it .index * $it .item } # 3 + 1*8 + 2*4 = 19
81+ $scores | reduce -n { | it, acc| $acc .item + $it .index * $it .item } # 3 + 1*8 + 2*4 = 19
8282` ` `
8383
8484# # Accessing the list
@@ -129,16 +129,16 @@ For example:
129129
130130` ` ` bash
131131# Do any color names end with "e"?
132- echo $colors | any? ($it | str ends-with " e" ) # true
132+ $colors | any? ($it | str ends-with " e" ) # true
133133
134134# Is the length of any color name less than 3?
135- echo $colors | any? ($it | str length) < 3 # false
135+ $colors | any? ($it | str length) < 3 # false
136136
137137# Are any scores greater than 7?
138- echo $scores | any? $it > 7 # true
138+ $scores | any? $it > 7 # true
139139
140140# Are any scores odd?
141- echo $scores | any? $it mod 2 == 1 # true
141+ $scores | any? $it mod 2 == 1 # true
142142` ` `
143143
144144The [` all? ` ](commands/all.md) command determines if every item in a list
@@ -147,16 +147,16 @@ For example:
147147
148148` ` ` bash
149149# Do all color names end with "e"?
150- echo $colors | all? ($it | str ends-with " e" ) # false
150+ $colors | all? ($it | str ends-with " e" ) # false
151151
152152# Is the length of all color names greater than or equal to 3?
153- echo $colors | all? ($it | str length) >= 3 # true
153+ $colors | all? ($it | str length) >= 3 # true
154154
155155# Are all scores greater than 7?
156- echo $scores | all? $it > 7 # false
156+ $scores | all? $it > 7 # false
157157
158158# Are all scores even?
159- echo $scores | all? $it mod 2 == 0 # false
159+ $scores | all? $it mod 2 == 0 # false
160160` ` `
161161
162162# # Converting the list
@@ -167,9 +167,9 @@ This can be called multiple times to flatten lists nested at any depth.
167167For example:
168168
169169` ` ` bash
170- echo [1 [2 3] 4 [5 6]] | flatten # [1 2 3 4 5 6]
170+ [1 [2 3] 4 [5 6]] | flatten # [1 2 3 4 5 6]
171171
172- echo [[1 2] [3 [4 5 [6 7 8]]]] | flatten | flatten | flatten # [1 2 3 4 5 6 7 8]
172+ [[1 2] [3 [4 5 [6 7 8]]]] | flatten | flatten | flatten # [1 2 3 4 5 6 7 8]
173173` ` `
174174
175175The [` wrap` ](commands/wrap.md) command converts a list to a table. Each list value will
0 commit comments