[humour] [ANN] Arbitrary Precision Arithmetic Library

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[humour] [ANN] Arbitrary Precision Arithmetic Library

Griffin Rock
Can someone help me get this onto LuaRocks?

-- dc.lua
return function (...)
  local cmd = 'dc "-e %s p"'
  local prg = table.concat({...}, " ")
  local dc = io.popen(cmd:format(prg))
  local result = dc:read(); dc:close()
  return result
end

-- example
x = "1"; y = "1"
for i = 1,100 do
  x,y = y,dc(x, y, "+")
end
print(y)
Reply | Threaded
Open this post in threaded view
|

Re: [humour] [ANN] Arbitrary Precision Arithmetic Library

Steve Litt
On Fri, 20 Dec 2019 02:44:04 +0000
Griffin Rock <[hidden email]> wrote:

> Can someone help me get this onto LuaRocks?
>
> -- dc.lua
> return function (...)
>   local cmd = 'dc "-e %s p"'
>   local prg = table.concat({...}, " ")
>   local dc = io.popen(cmd:format(prg))
>   local result = dc:read(); dc:close()
>   return result
> end
>
> -- example
> x = "1"; y = "1"
> for i = 1,100 do
>   x,y = y,dc(x, y, "+")
> end
> print(y)

Isn't that a Fibbonacci generator?

And this post brings up the question: Is there a Lua add-on that does
RPN arithmetic?

Thanks,

SteveT

Steve Litt
December 2019 featured book: Rapid Learning for the 21st Century
http://www.troubleshooters.com/rl21