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 (2999L/18K).

static LS ai_turnCertainWordsIntoUniqueDollarVars(Set<S> wordsToTransform, LS tok) {
  MultiSet<S> ms = ciMultiSet();
  ret mapWithIndex(tok, (t, i) ->
    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   

Travelled to 3 computer(s): mqqgnosmbjvj, tvejysmllsmz, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027132
Snippet name: ai_turnCertainWordsIntoUniqueDollarVars
Eternal ID of this version: #1027132/6
Text MD5: c61f88dd6459397d3a9985a533f95af7
Transpilation MD5: bb7dabdcc0edef38047c46a235228901
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-21 14:15:26
Source code size: 432 bytes / 9 lines
Pitched / IR pitched: No / No
Views / Downloads: 21 / 44
Version history: 5 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1027132 & http://1027132.tinybrain.de