Libraryless. Click here for Pure Java version (2747L/16K).
static ItIt<S> allWordsOfAlphabet_maxLength(int maxLength, S alphabet) { ret new ItIt<S>() { new L<Int> l; public bool hasNext() { ret l(l) <= maxLength; } public S next() { S s = makeString(); int i = 0; while (i < l(l)) { int n = l.get(i); if (n+1 < l(alphabet)) { l.set(i, n+1); break; } l.set(i++, 0); } if (i >= l(l)) l.add(0); ret s; } S makeString() { StringBuilder buf = new StringBuilder(l(l)); for (int i = 0; i < l(l); i++) buf.append(alphabet.charAt(l.get(i))); ret str(buf); } }; }
Began life as a copy of #1004581
download show line numbers debug dex old transpilations
Travelled to 5 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1030505 |
Snippet name: | allWordsOfAlphabet_maxLength |
Eternal ID of this version: | #1030505/1 |
Text MD5: | cdbd7b3ffd16ec69e1a1f12c3ee0e055 |
Transpilation MD5: | c44dba064d9223c63e7932e72c8432c9 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-01-02 17:31:17 |
Source code size: | 691 bytes / 31 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 217 / 291 |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1036339 - allUpDownSequencesOfMaxLength |