Download Jar. Libraryless. Click here for Pure Java version (7087L/50K).
!7 replace SimpleStatements with MatchableRecords<Prop>. replace Env with SimpleStatements. abstract sclass Prop implements IFieldsToList {} static withToList record Did$HappenBefore$<A, B>(A event1, B event2) {} static withToList record WhenDid$Happen(O event) extends Prop {} static withToList record $HappensAtSecond$<A, B>(A event, B y) extends Prop {} static O answer(Env env, O p) { if p is WhenDid$Happen(O event) ret env.fulfillVariable(var -> $HappensAtSecond$(event, var)); if p is Did$HappenBefore$(O event1, O event2) once { Int time1 = opt cast answer(env, WhenDid$Happen(event1)); if (time1 == null) break; Int time2 = opt cast answer(env, WhenDid$Happen(event2)); if (time2 == null) break; ret time1 < time2; } null; } p-exp { SimpleStatements env = new( $HappensAtSecond$("stuff", 10), $HappensAtSecond$("more stuff", 20)); assertEqualsVerbose(true, answer(env, print(Did$HappenBefore$("stuff", "more stuff")))); assertEqualsVerbose(false, answer(env, print(Did$HappenBefore$("more stuff", "stuff")))); assertEqualsVerbose(null, answer(env, print(Did$HappenBefore$("stuff", "any other stuff")))); }
Began life as a copy of #1025429
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, mqqgnosmbjvj, omdjrrnzbjjv, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1025431 |
Snippet name: | Propositions to objects, step 5 - multi-step procedure (OK) |
Eternal ID of this version: | #1025431/9 |
Text MD5: | 9958b974e288dba86191e92932809213 |
Transpilation MD5: | d84a146db582308e8cf839e0d8e771df |
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 00:20:23 |
Source code size: | 1206 bytes / 35 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 299 / 940 |
Version history: | 8 change(s) |
Referenced in: | [show references] |