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

26
LINES

< > BotCompany Repo | #1025427 // Propositions to objects, step 2: implement Prolog-style backwards rule (OK)

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

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

1  
!7
2  
3  
abstract sclass Prop implements IStatement, IFieldsToList {}
4  
5  
static withToList record $HappensBefore$<A, B>(A event1, B event2) extends Prop {}
6  
static withToList record $HappensAtDay$<A, B>(A event, B y) extends Prop {}
7  
static withToList record $LessThan$<A, B>(A x, A y) extends Prop {}
8  
static withToList record $BiggerThanOrEqualTo$<A, B>(A x, A y) extends Prop {}
9  
10  
// full define $LessThan(int x, int y) = x < y;
11  
static Bool checkProposition(Prop p) {
12  
  if p is $LessThan$(int x, int y) { ret x < y; }
13  
  if p is $BiggerThanOrEqualTo$(int x, int y) {
14  
    ret not(checkProposition($LessThan$(x, y)));
15  
  }
16  
  null;
17  
}
18  
19  
p-exp {
20  
  assertEqualsVerbose(true, checkProposition($LessThan$(1, 5)));
21  
  assertEqualsVerbose(false, checkProposition($LessThan$(5, 1)));
22  
  assertEqualsVerbose(null, checkProposition($LessThan$("what", "ever")));
23  
  assertEqualsVerbose(false, checkProposition($BiggerThanOrEqualTo$(1, 5)));
24  
  assertEqualsVerbose(true, checkProposition($BiggerThanOrEqualTo$(5, 1)));
25  
  assertEqualsVerbose(null, checkProposition($BiggerThanOrEqualTo$("what", "ever")));
26  
}

Author comment

Began life as a copy of #1025420

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: #1025427
Snippet name: Propositions to objects, step 2: implement Prolog-style backwards rule (OK)
Eternal ID of this version: #1025427/5
Text MD5: 897c56c673b04edb5882e9c23b6554ee
Transpilation MD5: 9da06fe979255c7e14c82aa34311d2f4
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:22:51
Source code size: 1101 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 314 / 1009
Version history: 4 change(s)
Referenced in: [show references]