Like @Piglet in the Comment wrote: 'you need to be very analytic about your work if you want to become a programmer.'
So for that analytic stuff you can use Lua standalone.
Give out what is relevant with print()
...
> function walkover(open, close)
>> local open, close, body = open or {1, 2, 3, 4, 5}, close or {6, 1, 3, 1, 10}, setmetatable({}, {__index = table})
>> print(#open .. ' Values in table open: ', body.concat(open, ', '))
>> print(#close .. ' Values in table close: ', body.concat(close, ', '))
>> print(#body .. ' Values in table body: ', body:concat(', '))
>> if #open == #close then for i=1, #open do if close[i] >= open[i] then body:insert(close[i] - open[i]) else body:insert(open[i] - close[i]) end end else error('Tables do not have same leng
th') end
>> print(#body .. ' Values in table body: ', body:concat(', '))
>> return body
>> end
> walkover()
5 Values in table open: 1, 2, 3, 4, 5
5 Values in table close: 6, 1, 3, 1, 10
0 Values in table body:
5 Values in table body: 5, 1, 0, 3, 5
table: 0x5661e300
> walkover({9,8,7,6,5},{4,3,2,1,0})
5 Values in table open: 9, 8, 7, 6, 5
5 Values in table close: 4, 3, 2, 1, 0
0 Values in table body:
5 Values in table body: 5, 5, 5, 5, 5
table: 0x5661e7f0
> walkover({9,8,7,6,5},{4,3,2,1,0,-1})
5 Values in table open: 9, 8, 7, 6, 5
6 Values in table close: 4, 3, 2, 1, 0, -1
0 Values in table body:
stdin:6: Tables do not have same length
stack traceback:
[C]: in function 'error'
stdin:6: in function 'walkover'
(...tail calls...)
[C]: in ?
This Example using the minimal error handling that checks the length of open against close and if equal do the math.
PS: If you dont understand the body
constructor: setmetatable({}, {__index = table})
This Constructor adds all table
Library function as methods.
This body
will also returned with its metamethods.
So this is possible too with walkover()
' return value...
print(walkover():concat(', '))