Last active
November 21, 2019 00:28
-
-
Save okram/11049c8682fac7708e05fd16e496342d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
This is now the general structure of an obj. | |
obj <= [x] | |
-a-> obj <= [x] | |
-b-> obj <= [x] | |
-c-> obj <= [x] | |
1. An obj has a "maps from" (<=) instruction sequence. This is how the obj is generated. | |
2. An obj has zero or more "state variables" (->). Their respective <= is computed every time the parent obj is mutated. | |
**/ | |
// this creates the int 1 with a single state variable called path. | |
// The path value is an empty list and on mutation, that list gets the parent obj appended to it ('this'). | |
mmadt> 1 -path-> [;] <= [put,0,[env,'this']] | |
==>1 | |
// example #1. 1 + 10 * 5 > 55. | |
mmadt> bool <= [start,1][plus,10][mult,5][gt,55] | |
==>false | |
// example #2. 1 + 10 * 5 > 55. | |
mmadt> bool <= [start,1-path->[;]<=[put,0,[env,'this']]][plus,10][mult,5][gt,55] | |
==>false | |
// example #3. 1 + 10 * 5 > 55 then get path | |
mmadt> lst <= [start,1-path->[;]<=[put,0,[env,'this']]][plus,10][mult,5][gt,55][env,'path'] | |
==>[false;11;1] | |
// example #4. Now with lots of starts. | |
mmadt> lst <= [start,1-path->[;]<=[put,0,[env,'this']],2-path->[;]<=[put,0,[env,'this']],3-path->[;]<=[put,0,[env,'this']]][plus,10][mult,5][gt,55][env,'path'] | |
==>[false;11;1] | |
==>[true;12;2] | |
==>[true;13;3] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment