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

33
LINES

< > BotCompany Repo | #1025387 - We Need [shortened]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 5786K of libraries. Click here for Pure Java version (9477L/49K).

!7

set flag AllowMetaCode. set flag Reparse. meta-transformNow { tok_standardBot }

standard bot WeNeed {
  Set<S> db = ciSet();
  
  S add(S s) { if (db.add(s)) change(); null; }
  S remove(S s) { ret db.remove(s) ? with(r change, "What a relief") : null; }
  S listWithPattern(S pat) { ret or2(lines(map(db, x -> format(ellipsisToStar(pat), x))), "nothing"); }
  S clearAfterConfirm() { ret "You're kidding, right?"; }

  sync S processSimplifiedLine(S s, O... _) {
    try answer super.processSimplifiedLine(s, _);
    new Matches m;
    
    meta {
      S program = [[
        We need ... = +
        We have ... = -
        Someone gave us ...|Someone gave me ... = -
        What do we need = listWithPattern("We need ...")
        We don't need ... anymore = -
        We need nothing|We don't need anything = clear after confirm
      ]];
      ret ai_lineEquationsToMatchX2Statements(jreplace_multi(program,
        "+", "add(\\$1);",
        "-", "remove(\\$1);",
        "clear after confirm", "clearAfterConfirm();"));
    }
    null;
  }
}

download  show line numbers  debug dex   

Travelled to 2 computer(s): mqqgnosmbjvj, tvejysmllsmz

No comments. add comment

Snippet ID: #1025387
Snippet name: We Need [shortened]
Eternal ID of this version: #1025387/9
Text MD5: ee1d4378f157593d5c7c0d15164ab07b
Transpilation MD5: 18eda4750450525542cf96ee751c84a4
Author: stefan
Category:
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-09-27 17:13:32
Source code size: 1086 bytes / 33 lines
Pitched / IR pitched: No / No
Views / Downloads: 35 / 102
Version history: 8 change(s)
Referenced in: [show references]