Libraryless. Click here for Pure Java version (3508L/22K).
1 | /* |
2 | finds patterns with a single changing token occurring at least twice |
3 | |
4 | inputs e.g. (with map splitAtSpaceTok(tlft(...))): |
5 | kgopkgorkgorkogrkkkbla makes sense |
6 | heldfdfdkfodkfodfkodlo makes sense |
7 | but 12345! makes no sense |
8 | but b1lubb makes no sense |
9 | |
10 | will find: |
11 | * makes sense [2] |
12 | but * makes no sense [2] |
13 | */ |
14 | |
15 | static MultiSet<S> findOneArgumentPatterns(LLS toks) { |
16 | MultiSet<S> patterns = ciMultiSet(); |
17 | MultiMap<Int, LS> byLength = indexListsByLength(lambdaMap simpleSpacesAndTrim(toks)); |
18 | |
19 | for (LLS toks2 : byLength.values()) { |
20 | for (int i = 1; i < l(first(toks2))-1; i += 2) { |
21 | int _i = i; |
22 | MultiSet<S> set = mapToCIMultiSet(toks2, tok -> join(cloneListReplacingElementAtIndex(tok, _i, "*"))); |
23 | patterns.addAll(multiSetWithoutSingles(set)); |
24 | } |
25 | } |
26 | ret patterns; |
27 | } |
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: | #1028730 |
Snippet name: | findOneArgumentPatterns |
Eternal ID of this version: | #1028730/2 |
Text MD5: | 7e15a1b98e8715804089d7d160b67883 |
Transpilation MD5: | 7a3b207fd6943659a94247f32d1a2297 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-07-06 16:23:34 |
Source code size: | 827 bytes / 27 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 210 / 297 |
Version history: | 1 change(s) |
Referenced in: | [show references] |