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

17
LINES

< > BotCompany Repo | #1027158 // recursiveJavaTok

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

Transpiled version (2508L) is out of date.

// returns L<S|L>
static L recursiveJavaTok(S s) {
  L tok = cloneList(javaTokWithBrackets(s));
  for (int i = 1; i < l(tok); i += 2) {
    S t = cast tok.get(i);
    if (startsWithOneOf(t, "(", "{")) {
      L sub = recursiveJavaTok(dropFirstAndLast(t));
      
      // add brackets to inner N tokens
      sub.set(0, first(sub) + takeFirst(1, t));
      sub.set(l(sub)-1, takeLast(1, t) + last(sub));
      
      tok.set(i, sub);
    }
  }
  ret tok;
}

Author comment

Began life as a copy of #1027139

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: #1027158
Snippet name: recursiveJavaTok
Eternal ID of this version: #1027158/11
Text MD5: ff91912cf5405c0eb495d5e160ce01db
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-22 17:32:12
Source code size: 472 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 193 / 304
Version history: 10 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)