Last active
December 29, 2015 04:59
-
-
Save ympbyc/7618886 to your computer and use it in GitHub Desktop.
ADT
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 (list a) | |
(cons a (list a)) | |
nil) | |
(data (tree a) | |
(node a (forest a))) | |
(data (forest a) | |
(list (tree a))) | |
(typefn true a a a) | |
(typefn cons a (list a) (list a)) | |
(typefn car (list a) a) | |
(typefn cdr (list a) (list a)) |
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 (list a) | |
(cons a (list a)) | |
nil) | |
;; --> generates --> | |
(typefn cons a (list a) (list a)) | |
(= cons x y f (f x y)) | |
(= nil 'nil) | |
;; user defines accessors | |
(= car xs (xs true)) | |
(= cdr xs (xs false)) | |
;;;;;;;;;;;;;;;;;;;; | |
(data (tree a) | |
(node a (forest a))) | |
(data (forest a) | |
(list (tree a))) | |
;; --> generates --> | |
(= node x y f (f x y)) | |
;; user defines accessors | |
(= tree-root nd (nd true)) | |
(= tree-forest nd (nd false)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment