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

14
LINES

< > BotCompany Repo | #1010329 // web_matchAllPerms - matches two webs in all permutations; returns null unless perfect match

JavaX fragment (include)

static Map<WebNode> web_matchAllPerms(Web patternWeb, Web inputWeb) {
  L<WebNode> patternNodes = web_nodes(patternWeb);
  L<WebNode> inputNodes = web_nodes(inputWeb);
  if (l(patternNodes) != l(inputNodes))
    null;
    //fail("Can't match, differing number of nodes: " + l(patternNodes) + "/" + l(inputNodes));
  
  LL<WebNode> perms = allPermutations(inputNodes);
  new Best<L<WebNode>> best;
  for (L<WebNode> perm : perms)
    best.put(perm, web_matchNodeLists(patternNodes, perm));
  L<WebNode> l = best.getIfScoreAbove(0);
  ret l == null ? null : twoListsToOrderedMap(patternNodes, l);
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1010329
Snippet name: web_matchAllPerms - matches two webs in all permutations; returns null unless perfect match
Eternal ID of this version: #1010329/4
Text MD5: 7f7bd2d2b662da9706dc0b329ba5bb6c
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-09-11 21:55:30
Source code size: 609 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 446 / 464
Version history: 3 change(s)
Referenced in: [show references]