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

17
LINES

< > BotCompany Repo | #1021250 // minusSignsSections - LinkedHashMap. now also returns prelude as ""

JavaX fragment (include)

static SS minusSignsSections(S text) {
  LS lines = lines(text);
  L<Int> l = indicesOfStartingWithTrim(lines, "--");
  new LinkedHashMap<S> out;
  if (nempty(l))
    mapPutIfNemptyValue(out, "", rtrim(lines(subList(lines, 0, first(l))));
  for i over l: {
    int i1 = l.get(i);
    int i2 = or(get(l, i+1), l(lines));
    S heading = trim(lines.get(i1));
    int iHeading = 0;
    while (iHeading < l(heading) && heading.charAt(iHeading) == '-') iHeading++;
    heading = trim(substring(heading, iHeading));
    out.put(heading, lines(subList(lines, i1+1, i2)));
  }
  ret out;
}

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: #1021250
Snippet name: minusSignsSections - LinkedHashMap. now also returns prelude as ""
Eternal ID of this version: #1021250/7
Text MD5: 53e2120e1058e49a46a42726f3ff291e
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-17 12:36:52
Source code size: 597 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 259 / 300
Version history: 6 change(s)
Referenced in: [show references]