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

20
LINES

< > BotCompany Repo | #1027865 // ai_scanOverListWithMatchFunctions

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (2751L) is out of date.

// preds return a MapSO or Bool
// (null is false)
// returns pairs (sublist, mapping)
static <A> LPair<L<A>, MapSO> ai_scanOverListWithMatchFunctions(L<A> l, IF1<A, O>... preds) {
  new LPair<L<A>, MapSO> out;
  search: for (L<A> sub : allSubListsOfLength_iterator(l(preds), l)) {
    MapSO map = ciMap();
    for i over sub: {
      O o = preds[i].get(sub.get(i));
      if (o cast Map) {
        if (!putAllStrictly(map, o)) continue search;
      } else if (o cast Bool) {
        if (!o) continue search;
      } else if (o == null) continue search;
      else { warn("Unknown predicate result: " + o); continue search; }
    }
    out.add(pair(sub, map));
  }
  ret out;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027865
Snippet name: ai_scanOverListWithMatchFunctions
Eternal ID of this version: #1027865/3
Text MD5: 350e78069e8f004360e7c8e039c70c95
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-04-16 13:02:30
Source code size: 697 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 214 / 317
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)