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

15
LINES

< > BotCompany Repo | #1031196 // lcLength

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

Libraryless. Click here for Pure Java version (2884L/17K).

static <A> int lcLength(LineCompedSingle<A> lc) {
  int n = 0;
  for (int symbol : lc.main)
    n += lcLength(lc, symbol);
  ret n;
}
  
static <A> int lcLength(LineCompedSingle<A> lc, int symbol) {
  if (symbol < l(lc.literals))
    ret 1;
  else {
    IntPair pair = lc.pairs.get(symbol-l(lc.literals));
    ret lcLength(lc, pair.a) + lcLength(lc, pair.b);
  }
}

Author comment

Began life as a copy of #1028483

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031196
Snippet name: lcLength
Eternal ID of this version: #1031196/7
Text MD5: c12e8c9cdeaaf254ea8dddd33c4986e6
Transpilation MD5: 7ecdd173b9df67481562f91d10d2e764
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-05-20 02:19:06
Source code size: 378 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 177 / 253
Version history: 6 change(s)
Referenced in: [show references]