* show looping by a counter index
* show accumulating data into an array
* show looping foreach object in an array
This commit is contained in:
Louis DeJardin 2018-10-20 12:39:26 -07:00 коммит произвёл GitHub
Родитель 9c10edd0d5
Коммит 093d3df4e1
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 38 добавлений и 13 удалений

Просмотреть файл

@ -1,18 +1,43 @@
operations:
- message: This operation will repeat 5 times...
values: # starts at zero
counter: 0
operations: # runs the nested operations
- message: (['Task one, counter is ', counter])
- message: (['Task two, counter is ', counter])
- message: This is an example of counting from 0 to 9
- message: and building an `append` object to add to a `data` array
- message: (['Looping... Index is ', index])
values: # count from 0 to 9 by 1
index: 0
data: []
operations:
- message: Nested work would go here
output:
append: # append[] is added to data[] below
- id: (index)
formula: ( bits(index) | [].to_string(@) | join(' + ', @) )
output:
data: ( [data, append] [] ) # combines array-of-arrays, then uses [] operator to flatten
index: (sum( [index, `1`] )) # increment index
repeat: # repeat until index is 10
condition: (index < `10`)
- message: This is an example of looping through items in an array
output: # increments counter before testing repeat.condition
counter: (sum( [counter, `1`] ))
- message: (['Looping... Current is ', to_string(current)])
values:
foreach: (data) # keep track of remaining data to iterate
current: (data[0]) # and make the current item easy to access
condition: ( length(foreach) > `0` ) # don't run if there's no data
repeat: # while repeat.condition is true, operations and output will run again
condition: counter < `5`
delay: PT.2S
timeout: PT3S
operations:
- message: Nested work would go here
output:
current: (foreach[1]) # advance to the next data item
foreach: (foreach[1:]) # reduce the remaining data to iterate
repeat:
condition: ( length(foreach) > `0` ) # stop when there is no remaining data