Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

37
LINES

< > BotCompany Repo | #1007684 // printNumberedLines - now clones the list first

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (4192L/24K).

/*static <A> L<A> printNumberedLines(L<A> l) {
  printNumberedLines((Collection<A>) l);
  ret l;
}

static <A> L<A> printNumberedLines(S prefix, L<A> l) {
  printNumberedLines(prefix, (Collection<A>) l);
  ret l;
}*/

svoid printNumberedLines(Map map) {
  printNumberedLines(mapToLines(map));
}

svoid printNumberedLines(S prefix, Map map) {
  printNumberedLines(prefix, mapToLines(map));
}

static <A extends Iterable> A printNumberedLines(A l) {
  int i = 0;
  if (l != null) for (O a : cloneList(l)) print((++i) + ". " + str(a));
  ret l;
}

static <A extends Iterable> A printNumberedLines(S prefix, A l) {
  int i = 0;
  if (l != null) for (O a : cloneList(l)) print(prefix + (++i) + ". " + str(a));
  ret l;
}

static void printNumberedLines(S prefix default "", O[] l) {
  printNumberedLines(prefix, wrapAsList(l));
}

static void printNumberedLines(O o) {
  printNumberedLines(lines(str(o)));
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney, xrpafgyirdlv

No comments. add comment

Snippet ID: #1007684
Snippet name: printNumberedLines - now clones the list first
Eternal ID of this version: #1007684/18
Text MD5: e690ff3b4719640da93bc0960949a73c
Transpilation MD5: bb85af7d45751cbc05c5b55a9a89ce39
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-06 04:08:51
Source code size: 938 bytes / 37 lines
Pitched / IR pitched: No / No
Views / Downloads: 693 / 745
Version history: 17 change(s)
Referenced in: [show references]