Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Creator: Bolodefchoco
- --Made in: 24/09/2016
- --Last update: 24/09/2016
- --[[ Notes:
- Does:
- Realiza contas a partir da posição das letras no alfabeto
- Args:
- e --> Conta (a + b)
- ]]--
- math.letter = function(e)
- local n1,op,n2 = e:match("(%a) *(%p) *(%a)")
- local get = function(l)
- local letters = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"}
- for k,v in next,letters do
- if v:lower() == l:lower() then
- return k
- end
- end
- return 0
- end
- local m
- local g1,g2 = get(n1),get(n2)
- if op == "+" then
- m = g1 + g2
- elseif op == "-" then
- m = g1 - g2
- elseif op == "*" then
- m = g1 * g2
- elseif op == "/" then
- m = g1 / g2
- elseif op == "^" then
- m = g1 ^ g2
- elseif op == "." then
- m = g1 + (g2/("1"..("0"):rep(#tostring(g2))))
- elseif op == "<" then
- m = g1 < g2
- elseif op == ">" then
- m = g1 > g2
- else
- m = g1 .. g2
- end
- return m,g1,g2
- end
Advertisement
Add Comment
Please, Sign In to add comment