get("#349") -- table functions -- an example text (taken from #523) text = [[ get("#515") -- splitLines text = getSnippet("#2000025") lines = splitLines(text) header = lines[1]:gsub(" +", " "):gsub("^ ", ""):gsub(" $", "") print(header) ]] function findReferences(text) refs = {} for word in text:gmatch("#%d+") do refs[word] = true end return keystolist(refs) end refs = findReferences(text) table.sort(refs) s = table.concat(refs, " ") print(s) assert(s == "#2000025 #515") return true
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
2 comment(s) hidden. show
Snippet ID: | #524 |
Snippet name: | Find snippet references in a text |
Eternal ID of this version: | #524/1 |
Text MD5: | 51bea7bb12e5ed575e36a3a9a17ccf71 |
Author: | stefan |
Category: | |
Type: | Lua code - System test |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-03-12 17:47:12 |
Source code size: | 530 bytes / 27 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 1156 / 209 |
Referenced in: | [show references] |