1 | static S centerPad(O s, int l) { |
2 | ret centerPad(s, l, ' '); |
3 | } |
4 | |
5 | static S centerPad(O s, int l, char c) { |
6 | S _s = str(s); |
7 | if (l(_s) >= l) ret _s; |
8 | int total = l-l(_s), left = total/2; |
9 | ret rep(c, left) + _s + rep(c, total-left); |
10 | } |
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: | 269 / 312 |
Referenced in: | [show references] |