i want to divide the whole list with one number.Lets say i take a variable $Content and i want to divide the following list with the 300 nodes. so i take the command $Content/300
- $Content= {1 2 3 4 5}{ 2 3 4 5 6} { 4 5 6 7 8 9}{3 4 6 8 9 0}
As a result output comes out {1 2 3 4 5}{ 2 3 4 5 6} { 4 5 6 7 8 9}{3 4 6 8 9 0}/300 with the parenthesis missing and invalid arguments.
Please tell me how we divide all list with the single number(300 nodes) because in curly brackets each number comes as an output of some arguments
Note that Tcl is a very whitespace-sensitive language, so you need a space between the close and open braces in your $Content declaration.
You can iterate over $Content, and for each sublist, iterate over the elements and divide by 300, collecting the results:
Output is
If your Tcl version is 8.6 you can use the
lmapcommand to shorten up the code:Note that I multiply by
1.0in order to use float division and not integer division.