Guided Practice 4.1 - Solution
The question was:
Consider the following data definition:
;; A ListOfStrings (LOS) is one of
;; -- empty
;; -- (cons String LOS)
Which of the following expressions have values that are LOS's?
Here are the answers:
- (cons "abc" empty) Answer: Yes. empty is a
LOS and "abc" is a string, so (cons "a" empty)
is a LOS
- (cons "bcd") Answer: No. This expression has no
value, because cons has the wrong number of
arguments.
- (cons "cde" (cons "ef" empty)) Answer: Yes. This is a LOS.
- (cons "3" (cons "4" empty)) Answer: Yes. This is also a LOS.
- (cons 3 (cons 4 empty)) Answer: No. 3 and 4 are numbers, not strings.
Last modified: Wed Aug 24 21:34:01 Eastern Daylight Time 2016