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

9
LINES

< > BotCompany Repo | #1027132 // ai_turnCertainWordsIntoUniqueDollarVars

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3040L/18K).

static LS ai_turnCertainWordsIntoUniqueDollarVars(Set<S> wordsToTransform, LS tok) {
  MultiSet<S> ms = ciMultiSet();
  ret mapWithIndex(tok, (i, t) ->
    odd(i) && contains(wordsToTransform, t) ? "$" + t + addPrefixIfNempty("_", emptyIfOne(ms.add(t))) : t);
}

sS ai_turnCertainWordsIntoUniqueDollarVars(Set<S> wordsToTransform, S s) {
  ret join(ai_turnCertainWordsIntoUniqueDollarVars(wordsToTransform, javaTok(s)));
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1027132
Snippet name: ai_turnCertainWordsIntoUniqueDollarVars
Eternal ID of this version: #1027132/7
Text MD5: bde041c0b62bc2ea5807f4a1d10b20c7
Transpilation MD5: 6e8025c1d2a3fc3c9f419c4c66f6d9f1
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-03-29 20:03:47
Source code size: 432 bytes / 9 lines
Pitched / IR pitched: No / No
Views / Downloads: 177 / 252
Version history: 6 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)