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.

// currently collection and map only
svoid pnlStruct(O o) {
  if (o cast Collection) pnlStruct(o);
  else if (o cast Map) pnlStruct(o);
  else if (o != null) pnlStruct(ll(o));
}

static <A, B extends Collection<A>> B pnlStruct(B l) {
  pnlStruct((Iterable<A>) l);
  ret l;
}

static <A> Iterable<A> pnlStruct(Iterable<A> l) {
  ret pnlStruct("", l);
}

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

static <A> A[] pnlStruct(A[] l) {
  pnlStruct(asList(l));
  ret l;
}

static <A, B> Map<A, B> pnlStruct(Map<A, B> map) {
  pnl(map(map, func(A a, B b) { sfu(a) + " = " + sfu(b) }));
  ret map;
}

Author comment

Began life as a copy of #1007684

download  show line numbers  debug dex   

Travelled to 10 computer(s): aoiabmzegqzx, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, tslmcundralx, tvejysmllsmz

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: 312 / 363
Version history: 14 change(s)
Referenced in: [show references]