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

10
LINES

< > BotCompany Repo | #1019772 // centerPad - pad (move contents to the middle)

JavaX fragment (include)

static S centerPad(O s, int l) {
  ret centerPad(s, l, ' ');
}

static S centerPad(O s, int l, char c) {
  S _s = str(s);
  if (l(_s) >= l) ret _s;
  int total = l-l(_s), left = total/2;
  ret rep(c, left) + _s + rep(c, total-left);
}

Author comment

Began life as a copy of #1009103

download  show line numbers  debug dex  old transpilations   

Travelled to 10 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1019772
Snippet name: centerPad - pad (move contents to the middle)
Eternal ID of this version: #1019772/1
Text MD5: a02dd644a2cdfbe06f96369c6dac9bf2
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-11-25 15:31:18
Source code size: 243 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 193 / 238
Referenced in: [show references]