proc or lappend/ string map ?
set max 14
set min 4
Add trailing zero’s considering min i.e. 4th position as 1 followed by adding zero’s till we reach (max-1)
Example in above case would be {1 0 0 0 0 0 0 0 0 0}
puts $result
{1 0 0 0 0 0 0 0 0 0}
Let’s say my min changes since its dynamic as it is a procedural argument.
set min 6
so my output should be
puts $results
{1 0 0 0 0 0 0 0}
Basically output always is calculated from 0 to 13 and whatever is my min we start from there and add 1 in its place and then add trailing zeros to (14-1)**
>Solution :
If I’m reading your examples correctly, this should work:
proc makelist {min max} {
concat 1 [lrepeat [expr {$max - $min - 1}] 0]
}
puts "{[makelist 4 14]}"
puts "{[makelist 6 14]}"
prints out
{1 0 0 0 0 0 0 0 0 0}
{1 0 0 0 0 0 0 0}