foreachset

SpecialNodes foreachset

input ports:
Name Type Description Optional

input

set<?0>

set to be iterated. must be non-empty.

no

output ports:
Name Type Description Optional

output

?0

an element of the set

no

final

bool

true if output is the last element of the set

yes

foreachset reads its input port without removing the value it reads. The value it reads is a set, which must be non-empty. It is an error if an empty set is read. For every element of the input set except the last, that element is output from the output port, and false is output on the final port. The last element of the set is then output from the output port, true is outupt on the final port, and the input set is removed from the input port. It is recommended that you read the Iteration section of the Dataflow in Coreograph document in addition to the information presented here.

The Special Nodes example foreachset is a slight variation on the foreachlist example above:

SpecialNodes foreachset2

Sets (of type set<int>) are built from the two initializers { 9, 4, 2, 1, 3, 7, 8, 5, 6, 10 } and { 1, 1, 2, 2, 3, 3, 4, 4, 4, 5 }. Set types in Transparency are ordered by their element values, meaning that the order in which elements are inserted is immaterial to the ordering. The output of Run is:

SpecialNodes foreachset3

The two sets that are input to foreachset are ordered by element value (i.e., sorted in numerical order), and devoid of replicas. The output from foreachset is similarly ordered and devoid of replicas.