Lua code - System test1 | get("#349") -- table functions
|
2 | |
3 | -- an example text (taken from #523) |
4 | |
5 | text = [[ |
6 | get("#515") -- splitLines
|
7 | text = getSnippet("#2000025")
|
8 | lines = splitLines(text) |
9 | header = lines[1]:gsub(" +", " "):gsub("^ ", ""):gsub(" $", "")
|
10 | print(header) |
11 | ]] |
12 | |
13 | function findReferences(text) |
14 | refs = {}
|
15 | for word in text:gmatch("#%d+") do
|
16 | refs[word] = true |
17 | end |
18 | return keystolist(refs) |
19 | end |
20 | |
21 | refs = findReferences(text) |
22 | table.sort(refs) |
23 | s = table.concat(refs, " ") |
24 | print(s) |
25 | assert(s == "#2000025 #515") |
26 | |
27 | 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: | 1944 / 274 |
| Referenced in: | [show references] |