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

30
LINES

< > BotCompany Repo | #1013225 // ai_patternSwitch

JavaX fragment (include)

1  
sbool ai_patternSwitch_debug;
2  
3  
static S ai_patternSwitch(S to, S s) {
4  
  ret ai_patternSwitch(ai_getOperator(s), to, s);
5  
}
6  
7  
static S ai_patternSwitch(S from, S to, S s) {
8  
  ret ai_patternSwitch(javaTokC(from), to, s);
9  
}
10  
11  
static S ai_patternSwitch(L<S> from, S to, S s) {
12  
  L<S> tok = javaTokPlusBracketsC_unquote(s);
13  
  L<S> tok1 = from, tok2 = javaTokC(to);
14  
  /*S op = ai_getOperator(s);
15  
  if (neq(from, op))
16  
    fail("Different operator: " + renderStructs(+from, +to, +op, +s));*/
17  
    
18  
  L<S> operands = ai_operands(from, s);
19  
  int iOperand = 0;
20  
  new L<S> out;
21  
  
22  
  for (S t : tok2) {
23  
    if (eq(t, "*"))
24  
      out.add(operands.get(iOperand++));
25  
    else
26  
      out.add(t);
27  
  }
28  
  if (ai_patternSwitch_debug) printStruct(+out);
29  
  ret joinWithSpace(out);
30  
}

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: 477 / 495
Version history: 5 change(s)
Referenced in: [show references]