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

27
LINES

< > BotCompany Repo | #1025429 // Propositions to objects, step 4 - fill variable from facts (OK)

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (7055L/50K).

1  
!7
2  
3  
replace Var with ValuelessVar.
4  
replace VarMap with Map<Var, O>.
5  
replace SimpleStatements with MatchableRecords<Prop>.
6  
7  
abstract sclass Prop implements IFieldsToList {}
8  
9  
static withToList record WhenDid$Happen(O event) extends Prop {}
10  
static withToList record $HappensAtSecond$<A, B>(A event, B y) extends Prop {}
11  
12  
static O answer(O p, SimpleStatements statements) {
13  
  if p is WhenDid$Happen(O event) {
14  
    ret statements.fulfillVariable(var -> $HappensAtSecond$(event, var));
15  
  }
16  
  null;
17  
}
18  
19  
p-exp {
20  
  SimpleStatements statements = new(
21  
    $HappensAtSecond$("stuff", 10),
22  
    $HappensAtSecond$("more stuff", 20)
23  
  );
24  
  assertEqualsVerbose(10, answer(print(WhenDid$Happen("stuff")), statements));
25  
  assertEqualsVerbose(20, answer(print(WhenDid$Happen("more stuff")), statements));
26  
  assertEqualsVerbose(null, answer(print(WhenDid$Happen("something else")), statements));
27  
}

Author comment

Began life as a copy of #1025428

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, omdjrrnzbjjv, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1025429
Snippet name: Propositions to objects, step 4 - fill variable from facts (OK)
Eternal ID of this version: #1025429/14
Text MD5: 913d8fd845e97d827a1999e628b75b7f
Transpilation MD5: af2ad6464b44ed655c1c433fa1cd3a54
Author: stefan
Category: javax / a.i.
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-09-28 23:52:17
Source code size: 901 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 257 / 915
Version history: 13 change(s)
Referenced in: [show references]