Oct 4 08:44 2013 complexUtilities.lua Page 1 --[[ Complex Number Utility Module H. Conrad Cunningham, Professor Computer and Information Science University of Mississippi Developed for CSci 658, Software Language Engineering, Fall 2013 1234567890123456789012345678901234567890123456789012345678901234567890 2013-09-22: Separated utilities module from representation modules --]] -- Function "square" takes an argument "x" and returns its square. local function square(x) return x * x end -- Function "show_data" converts raw Lua data structures to strings to -- assist in debugging and testing. This was not in the SICP Scheme -- package. local function show_data(d) if type(d) == "table" then local res = {} for k,v in pairs(d) do res[#res+1] = "[" .. show_data(k) .. "] = " .. show_data(v) end return "(" .. table.concat(res, ", ") .. ")" else return tostring(d) end end -- MODULE EXPORT LIST return { square = square, show_data = show_data }