Ask your own question, for FREE!
MIT 6.001 Structure and Interpretation of Computer Programs, Spring 2005 18 Online
OpenStudy (anonymous):

Hello, everyone. One question: what's the difference between '(1 5) and (list 1 5) in below context: (define (fun) '(1 5)) (set-car! (fun) 10) (fun) ;;==>(10 5), (fun) changed! ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define (fun) (list 1 5)) (set-car! (fun) 10) (fun) ;;==>(1 5), (fun) not changed!

OpenStudy (anonymous):

I guess they behave differently because list is a procedure, but quote is a special form. '(1 5) is equivalent to (quote (1 5)). If you define a variable instead of a procedure, like this: (define fun '(1 5)), then (set-car! fun 10) behaves identically in both cases.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!