Re: Should to_number return a sequence?
- Posted by petelomax 5 days ago
- 352 views
xecronix said...
Or if someone were inclined to be Phix and Euphoria compatible: (also not tested)
I'd suggest:
function parse_num(sequence s) atom b = is_number(s), v = 0 if b then v = to_number(s) end if return {b, v} end function
OTOH, I'm not at all sure how exactly that is supposed to beat just calling is/to inline directly.
euphoric said...
Isn't there a value() function that basically does this already?
(I searched the manual for value but could not find anything. Not even a search through Google worked.)
https://openeuphoria.org/docs/std_get.html#_2336_value
http://phix.x10.mx/docs/html/value.htm (incidentally, Example 1 of those docs is an isNumber() function...)
euphoric said...
I've always wondered if every return value (in Euphoria) should be of { SUCCESS_BOOL, RETURNED_VALUE }, but that seems way too verbose.
That's pretty much Go (aka golang) in a nutshell.