'(quote quote) in scheme

2019-02-25 10:33发布

I'm trying to learn scheme by myself. Could anyone tell me why '(quote quote) will output 'quote, and '(quote 'quote) will output ''quote?

Thank you very much!

2条回答
在下西门庆
2楼-- · 2019-02-25 11:01

This expression:

'(quote quote)

... after expanding '<something> to (quote <something>) is equivalent to (quote (quote quote)), notice that the symbol quote is being quoted two times, and this expression is evaluated and printed as ''quote.

On the other hand, this expression:

'(quote 'quote)

... is equivalent to (quote (quote (quote quote))), notice that the symbol quote is being quoted three times, and this expression is evaluated and printed as '''quote.

查看更多
成全新的幸福
3楼-- · 2019-02-25 11:01

Take a look at (free, online) How To Design Programs, intermezzo 2. It explains quote in terms of list and cons. If anything in that explanation doesn't make sense, just back up a bit in the textbook.

查看更多
登录 后发表回答