Download Jar. Libraryless. Click here for Pure Java version (7051L/50K).
!7 abstract sclass Prop implements IStatement, IFieldsToList {} static withToList record $HappensBefore$<A, B>(A event1, B event2) extends Prop {} static withToList record $HappensAtDay$<A, B>(A event, B y) extends Prop {} static withToList record $LessThan$<A, B>(A x, A y) extends Prop {} // we can fully define a statement on primitive values // full define $LessThan(int x, int y) = x < y; // we can output a variable // full define $LessThan(int x, var y) = y := any int bigger than x; /* Event 1 happens before event 2 := vars {event 1, event 2, X, Y} Event 1 happens at day X. Event 2 happens at day Y. X < Y. */ static Bool checkProposition(Prop p) { if p is $LessThan$(int x, int y) ret x < y; null; } p-exp { assertEqualsVerbose(true, checkProposition($LessThan$(1, 5))); assertEqualsVerbose(false, checkProposition($LessThan$(5, 1))); assertEqualsVerbose(null, checkProposition($LessThan$("what", "ever"))); }
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: | 411 / 1104 |
Version history: | 11 change(s) |
Referenced in: | #1025427 - Propositions to objects, step 2: implement Prolog-style backwards rule (OK) |