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

16
LINES

< > BotCompany Repo | #1014224 - simplifyWordTree

JavaX fragment (include)

static Map<S, O> simplifyWordTree(Map<S, O> tree) {
  if (tree == null) null;
  ret (Map) simplifyWordTree_impl(tree, true);
}

static O simplifyWordTree_impl(O tree, bool keepAsMap) {
  if (tree instanceof S) ret tree;
  Map<S, O> m = cast tree;
  if (!keepAsMap && l(m) == 1 && eq(firstKey(m), "<default>"))
    ret (S) firstValue(m);
  Map<S, O> map = similarEmptyMap(m);
  for (S key, O value : m) {
    map.put(key, simplifyWordTree_impl(value, false));
  }
  ret map;
}

Author comment

Began life as a copy of #1014222

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1014224
Snippet name: simplifyWordTree
Eternal ID of this version: #1014224/6
Text MD5: 8df7320b1bdbeba09bfe5514ee70a7df
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-04-16 03:21:25
Source code size: 490 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 212 / 241
Version history: 5 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1014224 & http://1014224.tinybrain.de