2016-06-30 89 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...))