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

15
LINES

< > BotCompany Repo | #1021528 // splitAtLinePredicate - split at lines satisfying a predicate

JavaX fragment (include)

// pred: func(S) -> bool
static L<S> mapLike splitAtLinePredicate(O pred, S text) {
  L<S> lines = toLines(text);
  new L<S> l;
  int i = 0;
  while (i < l(lines)) {
    int j = i;
    while (j < l(lines) && !callPred(pred, lines.get(j)))
      ++j;
    if (j > i)
      l.add(joinLines(lines.subList(i, j)));
    i = j+1;
  }
  ret l;
}

Author comment

Began life as a copy of #1003804

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1021528
Snippet name: splitAtLinePredicate - split at lines satisfying a predicate
Eternal ID of this version: #1021528/1
Text MD5: d834e746b085ebe17bf493f4af651097
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-02-17 14:49:47
Source code size: 351 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 224 / 237
Referenced in: [show references]