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

10
LINES

< > BotCompany Repo | #1021188 // replaceNumbersWithVars_returnMap

JavaX fragment (include)

static Pair<S, SS> replaceNumbersWithVars_returnMap(S s, final F0<S> varMaker) {
  final new SS map;
  ret pair(regexpReplace(s, "\\d+", func(Matcher m) -> S {
    S number = m.group();
    S var = map.get(number);
    if (var == null)
      map.put(number, var = varMaker!);
    ret var;
  }), map);
}

Author comment

Began life as a copy of #1021182

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1021188
Snippet name: replaceNumbersWithVars_returnMap
Eternal ID of this version: #1021188/3
Text MD5: 42ce5aa6f9ed23ad9f67dacdb09e3535
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-02-02 14:40:39
Source code size: 311 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 296 / 329
Version history: 2 change(s)
Referenced in: [show references]