lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hups. I overlooked your answer.. I will try it.. hopefully it will work ;)
Thanks for help
Oldrich Svec
______________________________________________________________
> Od: javier@guerrag.com
> Komu: Lua list <lua@bazar2.conectiva.com.br>
> CC: 
> Datum: 27.04.2006 23:30
> Předmět: Re: print("-5.3e - 10"*"2") doesnt work :/
>
> On Thursday 27 April 2006 3:15 pm, Oldrich Svec wrote:
> > Here (http://www.lua.org/pil/2.4.html) you can find an example of using
> > strings (print("-5.3e - 10"*"2")) but it doesn't work(attempt to perform
> 
> if this is scientific notation (-5.3 x 10^-10), remove the spaces around
> the 
> '-' and it works ok.
> 
> > arithmetic on a string value)... I use Lua 5.1.
> > Generaly I want to use it to calculate strings (fe. "5+1+4" =>
> > print("5+1+4"+"0") should give 10 but it doesnt work.. :(
> 
> use:
> 
> function calcstring (s)
> local f = loadstring ("return "..s)
> return f and f()
> end
> 
> print (calcstring ("5+1+4")) => 10
> 
> 
> -- 
> Javier
> 
>