Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/IJReid/Mathematics
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
--Module to calculate basic math values mathematics = {} mathematics.addition = function(input) --Addition function local sum = 0 --Define variable for use in loop for i, arg in pairs(input.args) do --Loop to run through all arguments sum = sum + arg --Add argument value to sum end return sum --Output the sum to the module end mathematics.subtraction = function(input) --Subtraction function local dif = input.args[1] - input.args[2] --Subtract second argument from first return dif --Outpud difference to module end mathematics.multiplication = function(input) --Multiplication function local product = 1 --Set product as 1 (so multiplication of it works) local pi = 3.141592653589793 --Set pi as 15 digits of precision for i, arg in pairs(input.args) do --Allow multiple arguments if (arg == "pi" or arg == "Ο" or arg == 3.14) then --Set pi to Ο argument arg = pi else product = product * arg --Multiply arguments together end end return product --Output product to module end mathematics.division = function(input) --Division function local quotient = input.args[1] / input.args[2] --Divide arg1 by arg2 return quotient --Output quotient to module end return mathematics --Output module to place of use
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Age in days
(
edit
)
Template:Module other
(
edit
)
Template:Module rating
(
edit
)
Template:Ombox
(
edit
)
Module:Arguments
(
edit
)
Module:Message box
(
edit
)
Module:Message box/configuration
(
edit
)
Module:Message box/ombox.css
(
edit
)
Module:Sandbox/IJReid/Mathematics
(
edit
)
Module:Sandbox/IJReid/Mathematics/doc
(
edit
)
Module:Yesno
(
edit
)