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

12
LINES

< > BotCompany Repo | #1014814 // asciiSideBySide - ASCII is a synonym for nonproportional text here

JavaX fragment (include)

1  
static S asciiSideBySide(L<S> texts) {
2  
  if (l(texts) < 2) ret unnull(first(texts));
3  
  if (l(texts) > 2) // nicely inefficient :)
4  
    ret asciiSideBySide(ll(asciiSideBySide(dropLast(texts)), last(texts)));
5  
  L<S> l1 = lines(first(texts)), l2 = lines(second(texts));
6  
  int col1 = maxStringLength(l1), n = max(l(l1), l(l2));
7  
  new StringBuilder buf;
8  
  for i to n:
9  
    buf.append(rpad(unnull(get(l1, i)), col1))
10  
      .append(unnull(get(l2, i))).append("\n");
11  
  ret str(buf);
12  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1014814
Snippet name: asciiSideBySide - ASCII is a synonym for nonproportional text here
Eternal ID of this version: #1014814/3
Text MD5: d1e303251bcbdc02bd56aa136188b940
Author: stefan
Category: javax / ascii
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-03 14:57:28
Source code size: 485 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 351 / 397
Version history: 2 change(s)
Referenced in: [show references]