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).

1  
static <A> int lcLength(LineCompedSingle<A> lc) {
2  
  int n = 0;
3  
  for (int symbol : lc.main)
4  
    n += lcLength(lc, symbol);
5  
  ret n;
6  
}
7  
  
8  
static <A> int lcLength(LineCompedSingle<A> lc, int symbol) {
9  
  if (symbol < l(lc.literals))
10  
    ret 1;
11  
  else {
12  
    IntPair pair = lc.pairs.get(symbol-l(lc.literals));
13  
    ret lcLength(lc, pair.a) + lcLength(lc, pair.b);
14  
  }
15  
}

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: 178 / 254
Version history: 6 change(s)
Referenced in: [show references]