Search
 
SCRIPT & CODE EXAMPLE
 

LUA

lua calculator

-- This only works for terminals!
-- if u dont have terminal I suggest doing 
--[[
print(number1 + number2)
]]

function add(a, b)
    return a + b
end

function minus(a, b)
    return a - b
end

function times(a, b)
    return a * b
end

function divide(a, b)
    return a / b
end

function cal(a, b, c)
    return c(a, b)
end

print("The first digits:")
local a = io.read("n","l")
print("+, -, * or /?")
local foo = io.read(1,"l")
print("The last digits")
local b = io.read("n","l")

if foo == "+" then
    operation = add
elseif foo == "-" then
    operation = minus
elseif foo == "*" then
    operation = times
elseif foo == "/" then
    operation = divide
end

print("")
print("Answer:")
print(cal(a, b, operation))
Comment

PREVIOUS NEXT
Code Example
Lua :: lua oop 
Lua :: how to make text different colors in LUA terminal 
Lua :: lua counting 
Lua :: lua empty table 
Lua :: lua print table 
Lua :: free roblux 
Lua :: Set core GUI Roblox 
Lua :: svelte template vite 
Lua :: gun that shoot automaticly roblox 
Lua :: lua pairs 
Lua :: Roblox studio increase variable when holding W 
Lua :: FiveM how to check where nearest player is store 
Lua :: open while loop lua 
Matlab :: to detect if a data frame has nan values 
Matlab :: octave mark axis labels 
Matlab :: tan in scilab 
Matlab :: matlab pan 
Basic :: Python: create zipfile 
Basic :: script to add value of 2 coulms of grid and show result in 3rd column 
Elixir :: elixir hello world 
Elixir :: elixir check is nil 
Scala :: scala schemaPayload json 
Scala :: get first string from list scala 
Actionscript :: truncate restart identity - syntax error at or near "identity" 
Excel :: excel paste delimited text into separate columns 
Perl :: perl hash ref create 
Pascal :: exceptions in pascal 
Powershell :: powershell replace character in string 
Clojure :: clojure read file 
Assembly :: x86 assembly hello world 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =