On Friday, May 6, 2022 at 12:28:00 PM UTC+2, Harald Oehlmann wrote:
> I wanted to find, if a list of bools (0/1 values) has one 1
>
> set list {0 0 1 0}
>
> ...
>
> Epilog: other solutions for the issue
>
> tcl::mathfunc::max 0 {*}$list
>
> Which does not support bools in any form. This is ok in my use-case.
>
> Or:
> -1 != [lsearch -integer $list 1]
Whether or not -integer is an advantage in your case depends on how the list is created. set list {0 0 1 0} holds strings.
Also, if lsearch is correct for your data, then operators "in"/"ni" will most likely be, too. So are bit-wise operators.
And for the fun of it: while max requires that 0 in case of empty lists, + does not, i.e. if {[::tcl::mathop::+ {*}$list]} works.