-4
(define p1 '(4 "the" "dog" "chewed" "the" "rug"))

(define p2 '(79 "on" "the" "rug" "slept" "the" "dog"))

(define p3 '(32 "the" "rug" "rats" "slept" "on"))

(define p4 '(42 "the" "meaning" "of" "life"))

给定列表 p1-p4 我想编写一个名为 get-page-number 的函数,该函数将从列表中提取数字。例子:

(get-page-number p2)将返回 79

然后我需要编写一个名为 get-words 的函数,它会删除数字并返回字符串。例子:

(get-words p1)会返回 "the" "dog" "chewed" "the" "rug"

4

2 回答 2

1

无需创建函数。car并且cdr会做。

(define get-page-number car)
(define get-words cdr)

(get-page-number p3) ; ==> 32
(get-words p3)       ; ==> ("the" "rug" "rats" "slept" "on")
于 2013-09-09T20:54:01.833 回答
0

尝试这个:

(define get-page-number car)
于 2013-09-09T20:52:59.100 回答