Libraryless. Click here for Pure Java version (3116L/19K).
1 | static Map<S, LS> lcMergeStringsOccurringOnce(Map<S, LS> encodings) {
|
2 | new MultiSet<S> ms; |
3 | for (LS l : values(encodings)) |
4 | ms.addAll(l); |
5 | ret mapValues(encodings, l -> {
|
6 | l = cloneList(l); |
7 | int i = 0; |
8 | while (i < l(l)-1) {
|
9 | int j = i; |
10 | while (j < l(l) && ms.get(l.get(j)) == 1) ++j; |
11 | if (j > i+1) |
12 | replaceSublist(l, i, j, ll(joinSubList(l, i, j))); |
13 | i++; |
14 | } |
15 | ret l; |
16 | }); |
17 | } |
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: | #1028860 |
| Snippet name: | lcMergeStringsOccurringOnce [for linecomp] |
| Eternal ID of this version: | #1028860/2 |
| Text MD5: | 768f0823b9f15cb9945e625b53ed4e55 |
| Transpilation MD5: | 03a08e39b59831550f19c1dfb0609104 |
| 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:15:30 |
| Source code size: | 438 bytes / 17 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 356 / 480 |
| Version history: | 1 change(s) |
| Referenced in: | [show references] |