Uses 1059K of libraries. Click here for Pure Java version (3412L/18K).
1 | !7 |
2 | |
3 | cmodule2 InputTreeTest > DynPrintLog { |
4 | concept Node { |
5 | new RefL<Node> followUps; |
6 | |
7 | toString { ret getString comment(this); } |
8 | } |
9 | |
10 | concept StringNode > Node { |
11 | S string; |
12 | |
13 | *() {} |
14 | *(S *string) {} |
15 | |
16 | toString { ret quote(string); } |
17 | } |
18 | |
19 | transient Node root; |
20 | transient LS texts = ll("Hello world", "Hello you"); |
21 | |
22 | start-thread { |
23 | root = new Node; |
24 | cset(root, comment := "Root"); |
25 | fOr (S text : texts) |
26 | addText(text); |
27 | printIndentedStruct(+root); |
28 | } |
29 | |
30 | void addText(S text) { |
31 | Node node = root; |
32 | for (S string : charactersAsStrings(text)) { |
33 | Node next = findObject(node.followUps, +string); |
34 | if (next == null) |
35 | node.followUps.add(next = cnew StringNode(+string)); |
36 | node = next; |
37 | } |
38 | } |
39 | } |
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1030585 |
Snippet name: | Input Tree Test [dev.] |
Eternal ID of this version: | #1030585/7 |
Text MD5: | 49412d3e4ad4f377fe6e7bb77457959b |
Transpilation MD5: | fb7606d742ba52dbf0e55dc9a7ad5f23 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-01-13 21:36:43 |
Source code size: | 819 bytes / 39 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 206 / 327 |
Version history: | 6 change(s) |
Referenced in: | [show references] |