2013-02-17 3 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) 
관련 문제