Libraryless. Click here for Pure Java version (1591L/11K/36K).
1 | !752 |
2 | |
3 | static L<E> poem; // reference poem |
4 | |
5 | p {
|
6 | L<Text> texts = loadPoems("#1003064"); // Simple Poem
|
7 | |
8 | poem = parsePoem(texts.get(0).lines); |
9 | printStructure(poem); |
10 | |
11 | L<E> test = parsePoem(texts.get(1).lines); |
12 | printStructure(test); |
13 | |
14 | L<E> failingTest = parsePoem(texts.get(2).lines); |
15 | printStructure("Failing test: ", failingTest);
|
16 | |
17 | S input = "q: are you on? "; |
18 | L<E> inp = parsePoem(input); |
19 | printStructure("Input: ", inp);
|
20 | |
21 | printStructure("Prediction: ", predict(inp));
|
22 | |
23 | print("Test: " + assertTrue(runPoemTest1(test)));
|
24 | print("Failing test: " + assertFalse(runPoemTest1(failingTest)));
|
25 | |
26 | print("OK!");
|
27 | } |
28 | |
29 | // used by runPoemTest1 |
30 | static L<E> predict(L<E> input) {
|
31 | int n = l(input); |
32 | if (l(poem) < n) ret null; // poem too short |
33 | |
34 | for (int i = 0; i < n; i++) {
|
35 | E x = poem.get(i), y = input.get(i); |
36 | if (!x.eqTo(y)) |
37 | ret null; |
38 | } |
39 | |
40 | ret subList(poem, n); |
41 | } |
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1003065 |
| Snippet name: | Test Simple Poem |
| Eternal ID of this version: | #1003065/1 |
| Text MD5: | c972833b7083d343bb8c80a44809a80a |
| Transpilation MD5: | aa15212a888910277f02a647ec54724b |
| Author: | stefan |
| Category: | eleu / nl |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2016-04-27 16:06:29 |
| Source code size: | 950 bytes / 41 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 927 / 1040 |
| Referenced in: | [show references] |