static IterableIterator<S> allWordsOfAlphabet_fixedLength(fS alphabet, final int length) { ret new IterableIterator<S>() { L<Int> l = rep((Int) 0, length); public bool hasNext() { ret true; // should change } 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)) null; 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 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1009424 | 
| Snippet name: | allWordsOfAlphabet_fixedLength | 
| Eternal ID of this version: | #1009424/3 | 
| Text MD5: | 0dbdbbae6cbcd10409e8f400f32c2188 | 
| Author: | stefan | 
| Category: | javax / a.i. | 
| Type: | JavaX fragment (include) | 
| Public (visible to everyone): | Yes | 
| Archived (hidden from active list): | No | 
| Created/modified: | 2017-09-06 19:59:32 | 
| Source code size: | 740 bytes / 31 lines | 
| Pitched / IR pitched: | No / No | 
| Views / Downloads: | 658 / 715 | 
| Version history: | 2 change(s) | 
| Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1017451 - allCombinations |