I get an argument in Tcl. How can I tell if it's a lambda function, other than usingcatch {apply $arg}
?
Thanks
check if an input is lambda in Tcl
76 views Asked by user1134991 At
2
There are 2 answers
2
On
Lambdas are syntactically lists where the first element is a well-informed list of lists (usual rules for formal arguments to proc), the second element is a script (with a very wide rangle of syntax possible) and the third element (if supplied) is a namespace name (it defaults to ::).
I'd check if you have a list of 2 or 3 elements where the first element is also a list (possibly empty). That should cover almost everything you'll ever see in practice.
Tcl does not have a built-in type for lambda functions.
catch {apply $arg}is the only option available. Any other thing that is out there will only be using some form of thecatch {apply $arg}.