文件名称:rational:lua 的有理数
文件大小:4KB
文件格式:ZIP
更新时间:2024-07-11 15:31:56
Lua
有理数 使用适当的运算符实现有理数运算。 用法示例: > rat = require ' rational ' > print ( rat ( 5 , 4 ) * rat ( 3 , 6 )) 5 / 8 > print ( rat ( 5 , 4 ) + rat ( 3 , 6 )) 7 / 4 > print ( rat ( 5 , 2 ) - rat ( 3 , 6 )) 2 > print ( rat ( 5 , 2 ) / rat ( 3 , 6 )) 5 > print ( rat ( 5 , 2 ) ^ 3 ) 125 / 8 > print ( - rat ( 5 , 6 )) - 5 / 6 > print ( rat ( 5 , 6 ) == rat ( 25 , 30 )) true > print ( rat ( 5 , 6 ) <= rat ( 25 , 30
【文件预览】:
rational-master
----COPYRIGHT.txt(2KB)
----rocks()
--------rational-scm-1.rockspec(475B)
----rational.lua(4KB)
----test()
--------test.lua(612B)
----README.md(742B)