Libraryless. Click here for Pure Java version (2502L/16K).
// effort doubles for each extra token static int magicQuotes_maxTokens = 10; static Set<S> magicQuotes(S input) { new LinkedHashSet<S> out; LS tok = javaTok(input); if (l(tok) <= magicQuotes_maxTokens) magicQuotes_impl(new L, asLinkedList(tok), false, out); ret out; } // Q: do remainingTokens start with an N or C token? svoid magicQuotes_impl(LS tokens, LS remainingTokens, bool inQuote, Set<S> out) { ping(); if (l(remainingTokens) < 2) out.add(inQuote ? join(tokens) + "\"" + join(remainingTokens) : join(tokens) + join(remainingTokens)); else { // case 1: don't insert a quote tokens.addAll(popFirst(2, remainingTokens)); magicQuotes_impl(tokens, remainingTokens, inQuote, out); remainingTokens.addAll(0, popLast(2, tokens)); // case 2: insert quote LS t = cloneTakeFirst(2, remainingTokens); if (inQuote) addAll(tokens, "\"" + first(t), second(t)); else addAll(tokens, first(t), "\"" + second(t)); removeFirst(2, remainingTokens); magicQuotes_impl(tokens, remainingTokens, !inQuote, out); removeLast(2, tokens); remainingTokens.addAll(0, t); } }
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1025352 |
Snippet name: | magicQuotes |
Eternal ID of this version: | #1025352/13 |
Text MD5: | 1c7a3c2b2a2394da15913b5389abf055 |
Transpilation MD5: | 3409a4d055536af8d0daa2c4de262132 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-10-01 21:31:03 |
Source code size: | 1188 bytes / 36 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 215 / 347 |
Version history: | 12 change(s) |
Referenced in: | [show references] |