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

32
LINES

< > BotCompany Repo | #1025420 // Propositions to objects, step 1: check primitive proposition (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  
9  
// we can fully define a statement on primitive values
10  
// full define $LessThan(int x, int y) = x < y;
11  
12  
// we can output a variable
13  
// full define $LessThan(int x, var y) = y := any int bigger than x;
14  
15  
/*
16  
  Event 1 happens before event 2 :=
17  
    vars {event 1, event 2, X, Y}
18  
    Event 1 happens at day X.
19  
    Event 2 happens at day Y.
20  
    X < Y.
21  
*/
22  
23  
static Bool checkProposition(Prop p) {
24  
  if p is $LessThan$(int x, int y) ret x < y;
25  
  null;
26  
}
27  
28  
p-exp {
29  
  assertEqualsVerbose(true, checkProposition($LessThan$(1, 5)));
30  
  assertEqualsVerbose(false, checkProposition($LessThan$(5, 1)));
31  
  assertEqualsVerbose(null, checkProposition($LessThan$("what", "ever")));
32  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1025420
Snippet name: Propositions to objects, step 1: check primitive proposition (OK)
Eternal ID of this version: #1025420/12
Text MD5: aa09d78fc6fc963911a391068f4a5f9a
Transpilation MD5: f54744ef21004db3f457be3701a1ac24
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-29 02:12:01
Source code size: 986 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 172 / 641
Version history: 11 change(s)
Referenced in: [show references]