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

44
LINES

< > BotCompany Repo | #1017538 // Computation Tree On Lists [dev.]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (7438L/54K).

!7

p-exp {
  ObjectNode root = new(mL("English sentence patterns"));
  
  //processNode_recursive(root, 10);
  ct_process_firstOnly(root, 10, 'ct_objectNodeToListNode);
  
  showFrame(jDynamicTree(root, ct_getChildren()));
}

svoid ct_process_firstOnly(CTNode n, int depthCounter, S... functions) {
  if (n == null || depthCounter <= 0) ret;
  if (nempty(n.children)) ret;
  
  for (S f : functions) {
    if (nempty(n.children)) ret;
    pcallF(f, n);
  }
  
  ct_process_firstOnly(first(n.children), depthCounter-1, functions);
}

svoid ct_objectNodeToListNode(CTNode n) {
  if (n instanceof ObjectNode) {
    ObjectNode on = cast n;
    O o = on.obj;
    
    if (o instanceof Collection)
      n.add(ListNode(asList((Collection) o)));
  }
}

sclass ListNode > CTNode {
  L list;
  
  *() {}
  *(L *list) {}
  
  S toString2() { ret sfu(list); }
  
  public bool equals(O o) { ret stdEq(this, o, 'list); }
  public int hashCode() { ret stdHash(this, 'list); }
}

Author comment

Began life as a copy of #1017536

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1017538
Snippet name: Computation Tree On Lists [dev.]
Eternal ID of this version: #1017538/6
Text MD5: 82c49d7e4f9166ee4b5c1627e4374691
Transpilation MD5: c78327c649da76a1aee4b6dec04c3ae0
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-07-26 14:08:35
Source code size: 1008 bytes / 44 lines
Pitched / IR pitched: No / No
Views / Downloads: 255 / 553
Version history: 5 change(s)
Referenced in: [show references]