1 | // assumes s is sorted |
2 | static S formatCharRange(S s) { |
3 | new L<S> l; |
4 | for (int i = 0; i < l(s); ) { |
5 | int j = i+1; |
6 | while (j < l(s) && s.charAt(j) == (char) (((int) s.charAt(j-1))+1)) ++j; |
7 | if (j == i+1) |
8 | l.add(S.format("%X", (int) s.charAt(i))); |
9 | else |
10 | l.add(S.format("%X", (int) s.charAt(i)) + "-" + S.format("%X", (int) s.charAt(j-1))); |
11 | i = j; |
12 | } |
13 | ret join(" ", l); |
14 | } |
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: | 526 / 532 |
Referenced in: | [show references] |