Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

39
LINES

< > BotCompany Repo | #1030585 // Input Tree Test [dev.]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 1059K of libraries. Click here for Pure Java version (3412L/18K).

!7

cmodule2 InputTreeTest > DynPrintLog {
  concept Node {
    new RefL<Node> followUps;
    
    toString { ret getString comment(this); }
  }
  
  concept StringNode > Node {
    S string;
    
    *() {}
    *(S *string) {}
    
    toString { ret quote(string); }
  }
  
  transient Node root;
  transient LS texts = ll("Hello world", "Hello you");
  
  start-thread {
    root = new Node;
    cset(root, comment := "Root");
    fOr (S text : texts)
      addText(text);
    printIndentedStruct(+root);
  }
  
  void addText(S text) {
    Node node = root;
    for (S string : charactersAsStrings(text)) {
      Node next = findObject(node.followUps, +string);
      if (next == null)
        node.followUps.add(next = cnew StringNode(+string));
      node = next;
    }
  }
}

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: 128 / 222
Version history: 6 change(s)
Referenced in: [show references]