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

30
LINES

< > BotCompany Repo | #1013225 // ai_patternSwitch

JavaX fragment (include)

sbool ai_patternSwitch_debug;

static S ai_patternSwitch(S to, S s) {
  ret ai_patternSwitch(ai_getOperator(s), to, s);
}

static S ai_patternSwitch(S from, S to, S s) {
  ret ai_patternSwitch(javaTokC(from), to, s);
}

static S ai_patternSwitch(L<S> from, S to, S s) {
  L<S> tok = javaTokPlusBracketsC_unquote(s);
  L<S> tok1 = from, tok2 = javaTokC(to);
  /*S op = ai_getOperator(s);
  if (neq(from, op))
    fail("Different operator: " + renderStructs(+from, +to, +op, +s));*/
    
  L<S> operands = ai_operands(from, s);
  int iOperand = 0;
  new L<S> out;
  
  for (S t : tok2) {
    if (eq(t, "*"))
      out.add(operands.get(iOperand++));
    else
      out.add(t);
  }
  if (ai_patternSwitch_debug) printStruct(+out);
  ret joinWithSpace(out);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1013225
Snippet name: ai_patternSwitch
Eternal ID of this version: #1013225/6
Text MD5: fb6969261aa338929a914cf688c31c7a
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-12-28 23:27:53
Source code size: 783 bytes / 30 lines
Pitched / IR pitched: No / No
Views / Downloads: 471 / 488
Version history: 5 change(s)
Referenced in: [show references]