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.

1  
// preds return a MapSO or Bool
2  
// (null is false)
3  
// returns pairs (sublist, mapping)
4  
static <A> LPair<L<A>, MapSO> ai_scanOverListWithMatchFunctions(L<A> l, IF1<A, O>... preds) {
5  
  new LPair<L<A>, MapSO> out;
6  
  search: for (L<A> sub : allSubListsOfLength_iterator(l(preds), l)) {
7  
    MapSO map = ciMap();
8  
    for i over sub: {
9  
      O o = preds[i].get(sub.get(i));
10  
      if (o cast Map) {
11  
        if (!putAllStrictly(map, o)) continue search;
12  
      } else if (o cast Bool) {
13  
        if (!o) continue search;
14  
      } else if (o == null) continue search;
15  
      else { warn("Unknown predicate result: " + o); continue search; }
16  
    }
17  
    out.add(pair(sub, map));
18  
  }
19  
  ret out;
20  
}

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: 213 / 317
Version history: 2 change(s)
Referenced in: [show references]