Download Jar. Libraryless. Click here for Pure Java version (7949L/54K).
1 | !7 |
2 | |
3 | p-autorestart { |
4 | new Matches m; |
5 | for (S s : printIterate(mL("Things that should be"))) { |
6 | temp tempIndent(); |
7 | //if "... should always be ..." |
8 | //printIndent("I'm asking: Are \*$1*/ \*$2*/?"); |
9 | |
10 | // Find question |
11 | S q = lookupNL(mechMap("Should => Question"), s); |
12 | if (q == null) continue with print("No question found"); |
13 | print(q); |
14 | |
15 | // Find code |
16 | S code = lookupNL(mechMap("Question => Iteration"), q); |
17 | if (code == null) continue with print("No code found"); |
18 | print(code); |
19 | |
20 | // Parse Forall |
21 | L<S> tok = javaTok(code); |
22 | int i = tok_forall(tok, m); |
23 | if (i < 0) continue with print("No forall found"); |
24 | print("For each " + $1 + ": " + $2); |
25 | |
26 | S innerCode = $2; |
27 | L<S> tok2 = javaTok($1); |
28 | S var = assertIdentifier(lastToken(tok2)); |
29 | S entity = trimJoin(dropLastToken(tok2)); |
30 | |
31 | S entityList = lookupNL(mechMap("Entity => List that lists all instances"), entity); |
32 | if (entityList == null) continue with print("No entity list found"); |
33 | L<S> entities = mL(entityList); |
34 | print("Have " + n2(entities, "entity", "entities") + " of type " + quote(entity) + "!"); |
35 | |
36 | new L<S> questions; |
37 | for (S e : entities) { |
38 | printIndent("QUESTION: " + addAndReturn(questions, jreplace(innerCode, var, e))); |
39 | } |
40 | |
41 | appendToMechList("Things that should be | Questions", questions); |
42 | } |
43 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1014418 |
Snippet name: | Things that should be => Questions (OK) |
Eternal ID of this version: | #1014418/25 |
Text MD5: | 4efcf926a13a09bff2ee157fa4bc2982 |
Transpilation MD5: | 2cd48a8fb2825209af41e5153d50d10d |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-04-21 18:54:47 |
Source code size: | 1421 bytes / 43 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 588 / 1562 |
Version history: | 24 change(s) |
Referenced in: | [show references] |