Talk:Arithmetic evaluation

Revision as of 03:01, 23 January 2008 by rosettacode>Sgeier (New section: [[Talk:Arithmetic Evaluator#TCL and [expr]|TCL and [expr]]])

Should we assume clean input or do we need to add in error checking? --Mwn3d 14:17, 11 December 2007 (MST)

Left unspecified (a solution can do either) User:Epsilon

TCL and [expr]

As is is written, this task is impossible in TCL since TCL has no concept of a "number" -- all variables are strings of bytes at the bottom and the only way to add a number to another one is to expressly declare some string to be interpreted as ... an expression. I.e. if variable "A" contains the string "3" then TCL has no idea that this might be a number. However [expr $A] would be a number (returned as a string again) and [expr $A+3] would be the string "6". Thus no matter how complicated my program might get, at some point I would have to invoke something like [expr $var1 $symbol $var2] (which would take the string formed by concatenating the contents of $var1, $symbol and $var2 and interpret them as an expression and return the result). This "bottom invocation", however would be prohibited by the task rules (and if I allow [expr] then I might as well just call [expr $original_string] and be done with the whole exercise in one line). Suggestions anybody? Sgeier 20:01, 22 January 2008 (MST)

Return to "Arithmetic evaluation" page.