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

31
LINES

< > BotCompany Repo | #1008537 // pnlStruct - print structures, numbered

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

Transpiled version (3405L) is out of date.

1  
// currently collection and map only
2  
svoid pnlStruct(O o) {
3  
  if (o cast Collection) pnlStruct(o);
4  
  else if (o cast Map) pnlStruct(o);
5  
  else if (o != null) pnlStruct(ll(o));
6  
}
7  
8  
static <A, B extends Collection<A>> B pnlStruct(B l) {
9  
  pnlStruct((Iterable<A>) l);
10  
  ret l;
11  
}
12  
13  
static <A> Iterable<A> pnlStruct(Iterable<A> l) {
14  
  ret pnlStruct("", l);
15  
}
16  
17  
static <A> Iterable<A> pnlStruct(S prefix, Iterable<A> l) {
18  
  int i = 0;
19  
  if (l != null) for (A a : l) print(prefix + (++i) + ". " + struct_noStringSharing(a));
20  
  ret l;
21  
}
22  
23  
static <A> A[] pnlStruct(A[] l) {
24  
  pnlStruct(asList(l));
25  
  ret l;
26  
}
27  
28  
static <A, B> Map<A, B> pnlStruct(Map<A, B> map) {
29  
  pnl(map(map, func(A a, B b) { sfu(a) + " = " + sfu(b) }));
30  
  ret map;
31  
}

Author comment

Began life as a copy of #1007684

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1008537
Snippet name: pnlStruct - print structures, numbered
Eternal ID of this version: #1008537/15
Text MD5: 7887444fe795761b6ce1eb841f924dcc
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-07-11 13:42:46
Source code size: 751 bytes / 31 lines
Pitched / IR pitched: No / No
Views / Downloads: 719 / 853
Version history: 14 change(s)
Referenced in: [show references]