function map(list, f) local tbl2, n, i = {}, #list, 1 for i=1, n do tbl2[i] = f(list[i]) end return tbl2 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: | 672 / 197 |
Referenced in: | [show references] |