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

17
LINES

< > BotCompany Repo | #1028861 // lcMergeStringsNotOccurringOnLHS [for linecomp]

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

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

// first file is assumed to be LHS
static Map<S, LS> lcMergeStringsNotOccurringOnLHS(Map<S, LS> encodings) {
  Set<S> lhs = asSet(firstValue(encodings));
  ret mapValues(encodings, l -> {
    if (l == firstValue(encodings)) ret l;
    l = cloneList(l);
    int i = 0;
    while (i < l(l)-1) {
      int j = i;
      while (j < l(l) && !lhs.contains(l.get(j))) ++j;
      if (j > i+1)
        replaceSublist(l, i, j, ll(joinSubList(l, i, j)));
      i++;
    }
    ret l;
  });
}

Author comment

Began life as a copy of #1028860

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: #1028861
Snippet name: lcMergeStringsNotOccurringOnLHS [for linecomp]
Eternal ID of this version: #1028861/1
Text MD5: d84ca5132e0df54682f461fa7cd90db7
Transpilation MD5: 989d4b54b586d27cb09c7ca052e8a9e3
Author: stefan
Category: javax / linecomp
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-10 14:18:55
Source code size: 494 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 95 / 158
Referenced in: [show references]