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

13
LINES

< > BotCompany Repo | #1028161 // combinationsForPositionalParser

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

Libraryless. Click here for Pure Java version (2941L/18K).

static BigInt combinationsForPositionalParser(int positions, IF1<Int, L<Int>> skipsFromPosition, O... _) {
  optPar bool debug;
  Map<Int, BigInt> combinationsFromPosition = autoTreeMap(() -> bigint(1));
  for (int i = positions-1; i >= 0; i--) {
    BigInt combinations = bigint(0);
    fOr (int skip : skipsFromPosition.get(i))
      combinations = plus(combinations, combinationsFromPosition.get(i+skip));
    if (debug)
      print("Combinations from " + i + ": " + combinations);
    combinationsFromPosition.put(i, combinations);
  }
  ret combinationsFromPosition.get(0);
}

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: #1028161
Snippet name: combinationsForPositionalParser
Eternal ID of this version: #1028161/6
Text MD5: 6af77d151b67dfbb42e5323cebdbef9e
Transpilation MD5: 1552390518c03ffd245ec2cb265c82cf
Author: stefan
Category: javax / stefan's os / nlp
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-05-23 18:51:17
Source code size: 592 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 154 / 225
Version history: 5 change(s)
Referenced in: [show references]