1 | sS ai_expandPatternForAAndAn(S s) {
|
2 | LS tok = javaTok(s); |
3 | if (!cicOneOf(tok, "a", "an") || contains(tok, "|")) null; // TODO: allow | |
4 | L<Int> indices = indicesOfAnyIC(tok, "a", "an"); |
5 | int n = l(indices); |
6 | if (n == 0) null; |
7 | new L<S> out; |
8 | for (L<S> l : allCombinations(rep(n, ll("a", "an")))) {
|
9 | for i over l: |
10 | tok.set(indices.get(i), l.get(i)); |
11 | out.add(join(tok)); |
12 | } |
13 | ret join("|", out);
|
14 | } |
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1017911 |
| Snippet name: | ai_expandPatternForAAndAn |
| Eternal ID of this version: | #1017911/5 |
| Text MD5: | a577a8d7a43f0d5d1277299a2ecd2d0a |
| Author: | stefan |
| Category: | javax / a.i. |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2018-08-22 23:06:13 |
| Source code size: | 427 bytes / 14 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 663 / 711 |
| Version history: | 4 change(s) |
| Referenced in: | [show references] |