2016-06-30 53 views
2

我试图用定义型编译合适的代数数据类型的引用:球拍:定义式参考

Books:     Author. Title. Publisher, City Year 
Articles from Magazines: Author. Title. Name of Magazine, Year 
Conference Contributions: Author. Title. Name of Conference. Publisher, City Year 

不幸的是我不知道如何来解决这个问题。虽然我确实知道define-type的特性及其与define-struct的区别。

任何人都可以指向正确的方向吗?这将不胜感激!

回答

1

假设define-typedefine-typehtdp2/abstraction

(define-type reference 
    (book (author string?) (title string?) (publisher string?) (city string?) (year number?)) 
    (magazine-article (author string?) ...etc...) 
    (conference-contribution (author string?) ...etc...))