2013-02-17 36 views
0

我在編寫簡單數據定義時遇到了困難。我需要知道你會如何寫一個用於以下各項編寫數據定義時遇到問題

因此,資料包括用戶的姓名,位置和關係狀態和 LOF(這是朋友的列表)。一位朋友由一個名字,地點和 關係狀態組成。你將如何編寫數據定義並提供 配置文件,朋友和lof的數據示例?

不知道,如果它這樣

;; A profile is one of: 
;; - empty 
;; - (make-user name location relationship-status LOF) 

回答

1

什麼也正是「麻煩」你與數據定義爲?他們都很簡單,幾乎直接翻譯了這個描述:

(define-struct profile (name location relationship-status lof)) 
(define-struct friend (name location relationship-status)) 

(define lof 
    (list 
    (make-friend "Lucy" "Minneapolis" 'married) 
    (make-friend "Schroeder" "Minneapolis" 'married) 
    (make-friend "Patty" "Minneapolis" 'open-relationship))) 

(make-profile "Charlie" "Minneapolis" 'widower lof) 
相關問題