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: | 689 / 203 |
Referenced in: | #345 - Horizontal split with crop #472 - Vertical split with crop #475 - Tolerant horizontal split with crop #478 - Horizontal split with crop (include) #480 - Horizontal split with crop 2 (include) #3000382 - Answer for ferdie (>> t = 1, f = 0) #3000383 - Answer for funkoverflow (>> t=1, f=0 okay) |