lua-users home
lua-l archive

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


Can also be used for expansion of positional notation

s = '1010' 
print((string.gsub(s, "()(.)", function (p, d) return ' + ' .. d .. '*2^' .. #s-p end))

+ 1*2^3 + 0*2^2 + 1*2^1 + 0*2^0

and base conversion.

-- Fidelis