I’ve been using lua for a month but stopped using it for a while. When I came back I made this simple code:
-- Remember, in a linear graph, the function is y = mx + b find the intercept-- m = 2 b = 4 function slopeFinder() print("y = mx + b") print("y = ".. m .."x + ".. b) print("Slope is ".. m ..", y-intercept is "..b) function graphDir() if m \> 0 then return(" Since the slope is ".. m.. ", the graph is positve. The direction will go up") end if m \< 0 then return(" Since the slope is ".. m.. ", the graph is negative. The direction will go down") end if m == 0 then return(" Since the slope is ".. m.. ", the graph is constant. The direction is straight or horizontal") end end function linearChk() if m ~= 0 then return(" The graph is linear") else return(" The graph is not linear") end end return (" The slope is ".. m.. " and the y-intercept is ".. b.. ".".. graphDir() .. ".".. linearChk() .. ".") ; end return slopeFinder();
Its pretty long (36 lines of code) and messy. It took me almost an hour trying to rework it after there were syntax errors. So is there a way to reduce the amount of lines in this code? I just hate having 36 lines just for a basic code that just returns 3 lines of words.