function map(list, f) local tbl2, n, i = {}, #list, 1 for i=1, n do tbl2[i] = f(list[i]) end return tbl2 end