Re: A function that expands value() and more

new topic     » goto parent     » topic index » view thread      » older message » newer message
euphoric said...
Senator said...

Just an observation. The function does not "Gets any numerical value at any position on a string", but rather gets or extracts the first numerical value found in the string and appends any subsequent numerical symbols to the initial numerical value.

print(1, val("This string includes the numbers 42 18 36."))  
-- outputs 
-- 421816 instead of 
-- 42 18 16 

So, the function should output a sequence of found values. In the case above, it would return {42,18,36}.

You can do this in Phix:

string s = "This string includes the numbers 42 18 36." 
sequence res = scanf(" "&s,"%s %d%s") 
pp(res,{pp_StrFmt,-2}) 
?vslice(res,2) 

Output:

{{" This string includes the numbers", 42, " 18 36."}, 
 {" This string includes the numbers 42", 18, " 36."}, 
 {" This string includes the numbers 42 18", 36, "."}} 
{42,18,36} 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu