Re: Should to_number return a sequence?

new topic     » goto parent     » topic index » view thread      » older message » newer message
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? grin

(I searched the manual for value but could not find anything. Not even a search through Google worked.) none

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. getlost

That's pretty much Go (aka golang) in a nutshell.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu