我正在使用Racket学习LISP! 我在解决这三个问题时遇到了问题。
1)(香蕉(Jane有一个后院))
2)(香蕉和简)
3)(((香蕉)和((简)))在她的后院)
以上面的列表形式,我怎么才能得到Jane? (使用汽车/司机)
答案 0 :(得分:3)
转到DrRacket中的“交互”窗口,然后将car
和cdr
的各种组合应用到每个列表中。
示例:
> (car '(banana in (Jane has a backyard)))
'banana
> (cdr '(banana in (Jane has a backyard)))
'(in (Jane has a backyard))
> (car (cdr '(banana in (Jane has a backyard))))
'in
> (cdr (cdr '(banana in (Jane has a backyard))))
'((Jane has a backyard))
> (cdr (cdr (cdr '(banana in (Jane has a backyard)))))
'()
> (car (cdr (cdr '(banana in (Jane has a backyard)))))
'(Jane has a backyard)
我很确定你可以从这里接管......