I'm study Linear Relationships in mathamatics, I came across the formatting of the table used to provide the positioning of each value of the Graph, Looking something like this...
Table[i] | Table[v]
1 3.50
2. 7.00
3. 10.50
4. 14.00
5. 17.50
For those who don't understand how liner equations work, they're simply a calculated line drawn on a positive to negative XY Graph, it takes the variable, usually a number. Multiplies it by how many times called, Eg, Table[i] (How many variables exist by interval; 0-#?) is 5. Table[v] is 3.50, the rest is self explanatory with the formatting of the table above.
I decided to take a chance on creating a complicated-ish algorithm on how to present the Graph through Console, here's what I've done. This is the formula table_[i]*variable
I am getting nothing, but blank space, not even a hextag. I know the algorithm is quite messy and probably wrong as I wrote it literally a few minutes ago, and am too busy with midterms to figure out the issue(s), could anyone tell me?
local table_ = {'startkey'}
local listlength, variable
local chart = {}
for i,_ in ipairs(table_) do
listlength = 5; variable = 3.50
if (type(variable) ~= "number") then error("variable '"..variable.."' isn't an integer.") end
table.remove(table_, 1)
for i_ = listlength, listlength, 1 do
if (#table_ ~= listlength) then
table.insert(table_, tonumber(i_))
else
break
end;
end;
table.insert(chart, table_[i]*variable)
end;
for i = 1,#table_ do
print(tostring(i)..[[ - ]]..table.concat(chart))
end;
Please don't mind the way I use ;, I'm transferring from another language, it also doesn't entirely effect the Script at all so it doesn't matter.
Thanks!

18 comments
My first guess is line 13. You did
table.insert(chart)but chart isn't defined as table as of yet.Checking for the type is simply by doing
if (type(value) == "number") then {...}I though that would happen too, only nothing really changes if I do '= {}'
Another problem is that the loop is starting from 5 and ending at 5 at line 06. Simply change from 1, listlength, as opposed to listlength, listlength. Or is it like supposed to be like that?
As well as another problem is that table_ is empty. Since it is empty, I doubt if the generic for loop is even looping at all.
Could I out a variable in there called 'startkey' then have it run for that, loop everything in, then once everythings in, it'll check again with the new stuff in the same loop?
Sure. That is up to you to decide. My job is to assist you whichever path you take on.
it's suppsoed to write 5,5,1 for an adding for loop
From my understanding, do you wish to print the multiples of 3.5?
Yes, I know this kethod is pointless, yet it still works, I do this for the teacher every unit, make an algorithm that calculates the work for everyone in class. Also, is the updates code better?
Writing effective algorithms must be your priority since you want to finish executing the code in the most linear time complexity you can get.
Yes, and method*;) also, does error() stop the script as if returning end?
error() stops the code and outputs the error message if given.
Thanks, would does the code above seem okay?
Seems too complicated for simple code tbh.
It may be, yet the method works perfectly fine, I'm just writing it this way to strech my knowledge and also make me look more nerdy;)
Well I posted my solution if you want to check it out
Please accept the answer if it helped you so we both earn some reputation point!