tcl::mathop list
The commands of the operators that test whether a list has an element.
tcl::mathop::in VALUE LIST
tcl::mathop::ni VALUE LIST
Description
in gives 1 when an element of LIST is the same string as VALUE, and ni gives 1 when no element is. The test compares strings, so in 2.0 {1 2 3} is 0. An empty LIST has no element.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| VALUE | string | required | The value to look for. |
| LIST | list | required | The list to search. |
Returns
1 or 0.
Examples
% tcl::mathop::in b {a b c}
1
% tcl::mathop::ni z {a b}
1
% tcl::mathop::in 2.0 {1 2 3}
0
% tcl::mathop::in {} {{}}
1
% tcl::mathop::ni {} {}
1
Errors
% tcl::mathop::in a
wrong # args: should be "tcl::mathop::in value list"
-errorcode TCL WRONGARGS
% tcl::mathop::ni a b c
wrong # args: should be "tcl::mathop::ni value list"
-errorcode TCL WRONGARGS
% tcl::mathop::in a "{"
unmatched open brace in list
-errorcode TCL VALUE LIST BRACE
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.1