Online Lua Compiler

Distance = Distance or {} -- Allow addition to namespace function Distance.onedim(start, stop) return (start > stop) and start - stop or stop - start end function Distance.twodim(start, stop) local xdiff = start[1] - stop[1] local ydiff = start[2] - stop[2] local summer = xdiff * xdiff + ydiff * ydiff return math.sqrt(summer) end print(Distance.onedim(5,10))