Dear TCL team,
Unfortunately, "tcl::mathop::||" does not exist. Probably, this is due
to the fact, that it is handled internally in expr.
IMHO, it would be great, if it would exist, even if not used in expr.
Thank you all,
Harald
On 5/6/2022 3:57 PM, Harald Oehlmann wrote:
Dear TCL team,
Unfortunately, "tcl::mathop::||" does not exist. Probably, this is due
to the fact, that it is handled internally in expr.
IMHO, it would be great, if it would exist, even if not used in expr.
Thank you all,
Harald
My *guess* is that it's because the expected semantics of || in almost
all languages are short-circuit operation so later arguments do not get evaluated.
For example
(bin) 4 % expr {1 || $undefined}
1
It is not possible to implement this behavior with the command argument
Tcl syntax.
/Ashok
On 5/6/2022 3:57 PM, Harald Oehlmann wrote:
Dear TCL team,
Unfortunately, "tcl::mathop::||" does not exist. Probably, this is due
to the fact, that it is handled internally in expr.
IMHO, it would be great, if it would exist, even if not used in expr.
Thank you all,
Harald
My *guess* is that it's because the expected semantics of || in almost
all languages are short-circuit operation so later arguments do not get evaluated.
For example
(bin) 4 % expr {1 || $undefined}
1
It is not possible to implement this behavior with the command argument
Tcl syntax.
/Ashok
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]
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 497 |
Nodes: | 16 (2 / 14) |
Uptime: | 10:18:05 |
Calls: | 9,781 |
Files: | 13,748 |
Messages: | 6,187,185 |