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

18
LINES

< > BotCompany Repo | #1008125 // matchCondition_random

JavaX fragment (include)

1  
static bool matchCondition_random(Lisp condition, Map<S, Lisp> m) {
2  
  L<Lisp> facts = lispTruth();
3  
  
4  
  O evaluator = getLispEvaluator(condition.head);
5  
  if (evaluator != null)
6  
    ret isTrue(callF(evaluator, lispReplaceVars(condition, m)));
7  
8  
  L<Map<S, Lisp>> candidates = new L;
9  
  for (Lisp fact : facts) {
10  
    Map<S, Lisp> m2 = cloneMap(m);
11  
    if (lispMatchIC_xyzVars_sub(condition, fact, m2))
12  
      candidates.add(m2);
13  
  }
14  
  //print("Have " + n(candidates, "candidate"));
15  
  if (empty(candidates)) false;
16  
  m.putAll(random(candidates));
17  
  true;
18  
}

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: #1008125
Snippet name: matchCondition_random
Eternal ID of this version: #1008125/1
Text MD5: 10bb2e5fb4a48d33e1e88dfd049c892f
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 15:54:28
Source code size: 571 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 616 / 575
Referenced in: [show references]