loop commandThis is a generic command for iterating over containers.
- loop <varList> <container> <script>
% loop v [list a b c d] { puts $v } a b c d % loop {i v} [list a b c d] { puts "$i $v" } 0 a 1 b 2 c 3 d % loop v [map create {alpha a baker b}] { puts $v } a b % loop {i v} [map create {alpha a baker b}] { puts "$i $v" } alpha a baker b
accessor commands
- getx <container> <key> ?<key> ...?
- Returns the value associated with the key in the specified container. If more than one key is specified then each subsequent key is looked up in the container returned from the previous search.
% set a [list [vector create 1 2 3]] {<feather::vector 0x200438a8>} % getx $a 0 <feather::vector 0x200438a8> % getx $a 0 1 2
- setx <container> <key> ?<key> ...? <value>
- Sets the value associated with the key in the container. The multi-key format is shorthand.
setx <container> <key1> <key2> <key3> <key4> <value> is equivalent to setx [getx <container> <key1> <key2> <key3>] <key4> <value> % set a [list [vector create 1 2 3]] {<feather::vector 0x200438a8>} % setx $a 0 99 lists are read-only % setx $a 0 1 99 % vector contents [getx $a 0] 1 99 3
count command
- count <container>
- Returns the number of elements in the container.