Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --1st problem
- table_element(table, number)
- return table[number]
- end
- --2nd problem
- last_table_element(table)
- return table[#table]
- end
- --3th problem
- last_second_table_element(table)
- return table[#table - 1]
- end
- --4th problem
- lenght_of_array(table)
- return #table
- end
- --5th problem - I think on this about 30 mins!
- reverse_table(table)
- local l = {}
- for n = 1, #table do
- l[#table + 1 - n] = t[n]
- end
- return l
- end
- --6th problem - hardest one!
- function table_in_palidrome(table)
- local n = math.floor(#table / 2)
- for p = 1, n do
- if table[p] ~= table[#table - p + 1] then
- return false
- end
- end
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement