foreach
Iterate over elements of one or more lists.
Syntax
tcl
foreach varList list ?varList2 list2 ...? commandParameters
- varList: Variable name or list of variable names to bind
- list: List of values to iterate over
- varList2, list2: Additional variable/list pairs for synchronized iteration
- command: Script to execute for each iteration
Examples
Simple iteration
Output
Multiple variables per iteration
Output
Parallel list iteration
Output
Building a result
Output
Using continue to skip items
Output
