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

15
LINES

< > BotCompany Repo | #1012681 // shortenSymbol

JavaX fragment (include)

please include function shorten.

static Symbol shortenSymbol(Symbol s) { ret shortenSymbol(s, shorten_default); }

static Symbol shortenSymbol(Symbol s, int max) {
  ret shortenSymbol(s, max, "...");
}

static Symbol shortenSymbol(Symbol s, int max, S shortener) {
  if (s == null) ret emptySymbol();
  if (max < 0) ret s;
  return s.length() <= max ? s : symbol(substring(str(s), 0, min(s.length(), max-l(shortener))) + shortener);
}

static Symbol shortenSymbol(int max, Symbol s) { ret shortenSymbol(s, max); }

Author comment

Began life as a copy of #1000644

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: #1012681
Snippet name: shortenSymbol
Eternal ID of this version: #1012681/2
Text MD5: 2dc90c47ef0c8694ad53660e8e33b520
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-12-10 07:19:44
Source code size: 528 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 391 / 413
Version history: 1 change(s)
Referenced in: [show references]