Last active
August 29, 2015 14:02
-
-
Save BekaValentine/d6f23ff589859e255179 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
| data IntList = nil | cons(int,IntList) | |
| is sugar for | |
| enum IntListCon { nilCon , consCon }; | |
| struct IntList { IntListCon con ; int head ; IntList* tail; }; | |
| struct IntList nil; | |
| nil.con = nilCon; | |
| struct IntList cons(int x, IntList* xs) { | |
| struct IntList xs'; | |
| xs'.con = consCon; | |
| xs'.head = x; | |
| xs'.tail = xs; | |
| return xs'; | |
| } | |
| and | |
| case xs of { | |
| nil -> f | |
| cons(x,xs') -> g | |
| } | |
| is sugar for | |
| if (nilCon == xs.con) { | |
| f | |
| } else if (consCon == xs.con) { | |
| int x = xs.head; | |
| IntList* xs' = xs.tail; | |
| g | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment