I have the following code and its evaluation as comment:
(require scheme/mpair)
(list) ;; '()
(mlist) ;; '()
(cons 'un (list)) ;; '(un)
(list 'un (list)) ;; '(un ())
(mcons 'un (mlist)) ;; (mcons 'un '())
(mlist 'un (mlist)) ;; (mcons 'un (mcons '() '()))
My questions:
-
why doesn’t the 3rd expression return
'(), instead of'(un . ())? -
why don’t the 5th expression and the the 6th expression return the same thing?
As a general example,
(list x y z)is an abbreviation for(cons x (cons y (cons z empty))). And(list)is an empty list, i.e.empty. So(list 'un (list))is just an abbreviation for(cons 'un (cons empty empty))– I.e. a list with two elements in it: the symbol'unand an empty list.mlistsimilarly is an abbreviation for a sequence ofmcons‘es ontoemptyat the very end.