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

18
LINES

< > BotCompany Repo | #1008124 // matchConditions_random

JavaX fragment (include)

// if match: returns -1
// if no match: returns how many conditions were met
static int matchConditions_random(L<Lisp> conditions, Map<S, Lisp> m) {
  if (empty(conditions)) ret -1;
  Lisp condition = first(conditions);
  Map<S, Lisp> m2 = cloneMap(m);
  if (!matchCondition_random(condition, m2)) {
    print("Condition failed: " + condition);
    ret 0;
  }
  print("Condition matched, " + struct(m2));
  int n = matchConditions_random(dropFirst(conditions), m2);
  if (n == -1) {
    m.putAll(m2);
    ret -1;
  }
  ret n+1; // failure
}

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: #1008124
Snippet name: matchConditions_random
Eternal ID of this version: #1008124/1
Text MD5: ad80a502205884c848d6a193e073e6c4
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-04-25 14:17:18
Source code size: 559 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 466 / 498
Referenced in: [show references]