1 | function map(list, f) |
2 | local tbl2, n, i = {}, #list, 1 |
3 | for i=1, n do |
4 | tbl2[i] = f(list[i]) |
5 | end |
6 | return tbl2 |
7 | end |
A nice little map function (for lists) for you to copy or include :-)
test run test run with input download show line numbers
Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #337 |
Snippet name: | map |
Eternal ID of this version: | #337/1 |
Text MD5: | 0daa29a276ef0bb5f079b88451157c45 |
Author: | stefan |
Category: | |
Type: | Lua code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-01-30 15:38:50 |
Source code size: | 126 bytes / 7 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 673 / 198 |
Referenced in: | [show references] |