質問編集履歴
1
自分なりの回答を追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -56,7 +56,7 @@
|
|
56
56
|
|
57
57
|
; Value: (anne marrie heather)
|
58
58
|
|
59
|
-
(family-name (make-person "williams" "anne
|
59
|
+
(family-name (make-person "williams" "anne" "marie" "heather"))
|
60
60
|
|
61
61
|
; Value: williams
|
62
62
|
|
@@ -74,6 +74,68 @@
|
|
74
74
|
|
75
75
|
|
76
76
|
|
77
|
+
###追記です.
|
78
|
+
|
79
|
+
まず,最初の3問についてですが,以下のように関数を定義して解決しました.
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
```lisp
|
84
|
+
|
85
|
+
>(define (names x)
|
86
|
+
|
87
|
+
(car x))
|
88
|
+
|
89
|
+
> (names test-person)
|
90
|
+
|
91
|
+
'("james" "tom" "harry")
|
92
|
+
|
93
|
+
> (define (salary x)
|
94
|
+
|
95
|
+
(car (cdr x)))
|
96
|
+
|
97
|
+
> (salary test-person)
|
98
|
+
|
99
|
+
300000
|
100
|
+
|
101
|
+
(define (position x)
|
102
|
+
|
103
|
+
(cdr (cdr x)))
|
104
|
+
|
105
|
+
> (position test-person)
|
106
|
+
|
107
|
+
'("president")
|
108
|
+
|
109
|
+
```
|
110
|
+
|
111
|
+
さらに,最後の2問ですが以下のように関数を定義して解決しました.
|
112
|
+
|
113
|
+
```lisp
|
114
|
+
|
115
|
+
> (define (given-names x)
|
116
|
+
|
117
|
+
(cdr x))
|
118
|
+
|
119
|
+
> (given-names (make-person "williams" "anne" "marie" "heather"))
|
120
|
+
|
121
|
+
'("anne" "marie" "heather")
|
122
|
+
|
123
|
+
> (define (family-name x)
|
124
|
+
|
125
|
+
(car x))
|
126
|
+
|
127
|
+
> (family-name (make-person "williams" "anne" "marie" "heather"))
|
128
|
+
|
129
|
+
"williams"
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
```
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
77
139
|
###補足情報(言語/FW/ツール等のバージョンなど)
|
78
140
|
|
79
141
|
実行環境は[DrRacket](https://racket-lang.org/)です.
|