M bank-account/bank-account.lua +7 -7
@@ 1,6 1,6 @@
-local BankAccount = {}
+local ba = {}
-function BankAccount:new()
+function ba:new()
local account = {
current_bal = 0,
closed = false
@@ 10,16 10,16 @@ function BankAccount:new()
return account
end
-function BankAccount:balance()
+function ba:balance()
return self.current_bal
end
-function BankAccount:deposit(amount)
+function ba:deposit(amount)
assert(not self.closed and amount > 0)
self.current_bal = self.current_bal + amount
end
-function BankAccount:withdraw(amount)
+function ba:withdraw(amount)
assert(amount > 0 and
amount < self.current_bal and
not self.closed and
@@ 28,8 28,8 @@ function BankAccount:withdraw(amount)
self.current_bal = self.current_bal - amount
end
-function BankAccount:close()
+function ba:close()
self.closed = true
end
-return BankAccount
+return ba
M run-length-encoding/run-length-encoding.lua +1 -1
@@ 12,7 12,7 @@ end
function rle.decode(input)
local dec = ""
for n, c in input:gmatch("(%d*)(%D)") do
- dec= dec.. c:rep(n == "" and 1 or tonumber(n))
+ dec = dec .. c:rep(n == "" and 1 or tonumber(n))
end
return dec
end