зеркало из https://github.com/microsoft/Atlas.git
Updating looping example (#75)
* show looping by a counter index * show accumulating data into an array * show looping foreach object in an array
This commit is contained in:
Родитель
9c10edd0d5
Коммит
093d3df4e1
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче