// assumes s is sorted static S formatCharRange(S s) { new L<S> l; for (int i = 0; i < l(s); ) { int j = i+1; while (j < l(s) && s.charAt(j) == (char) (((int) s.charAt(j-1))+1)) ++j; if (j == i+1) l.add(S.format("%X", (int) s.charAt(i))); else l.add(S.format("%X", (int) s.charAt(i)) + "-" + S.format("%X", (int) s.charAt(j-1))); i = j; } ret join(" ", l); }
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1004647 |
Snippet name: | formatCharRange |
Eternal ID of this version: | #1004647/1 |
Text MD5: | 2b67f7324e3b692bc943e3e2772f8dc3 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-08-24 20:18:10 |
Source code size: | 411 bytes / 14 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 525 / 531 |
Referenced in: | [show references] |