;CSC104 Fall 2019 Exercise 3Print out and fill in by hand, then hand in to the TA at the start of your quiz.
; UTorID login id : ;Surname:
; Given Name :
;Question 1.
; The functions empty? , first , rest , and reverse each require a single argument of type list. ; Write out the following steps
step map unary? list empty? first rest reverse
; Beside the following expression write down its value
map binary? list empty? first rest reverse
; The function empty? determines whether its argument has no elements, in other words whether the length of the list is zero.
; Beside each of the following four expressions, write down its value, or the word error if it produces an error
empty? empty? listempty? list empty?
; The functions first and rest require a nonempty list argument.
; The function first produces the first element of its argument.
; The function rest produces its argument but without the arguments first element. ; For each of the following, write down the steps
step first list textjoin a nt textimage bee1 2
step rest list textjoin a nt textimage bee1 2
; Beside each of the following twelve expressions, write down its value, or the word error if it produces an error
first ant bee cat dog rest ant bee cat dog reverse ant bee cat dog
first list rest list reverse list
first list ant bee rest list ant bee reverse list ant bee
first list ant rest list ant reverse list ant
; The function reverse produces its argument but with the arguments elements in reverse order. For the following, write down the steps
step first reverse rest reverse list50 7 filledsquare 10 textjoin e mu
;Question 2.
; For each of the following function definitions, IF IT IS GRAMMATICALLY CORRECT THEN write down the values of the two expressions following it,
;
and write down the steps for the corresponding expression that calls it, including any error messages during those steps
define f.1 10 oval 20 10
define f.2 x oval 20 10
define f.3 text textjoin text !
define f.4 list a b rotate triangle a b
define f.5 list a b map circle list a b
define f.6 a b map circle a b
define f.7 a b
map circle list b a
define f.8 a map circle
a
define f.9 a map circle
list a define f.10 a b
scale a b define f.11 amy
textjoin amy !
define f.12 amy textjoin amy
!
define f.13 amy amy amy
define f.14 amy textjoin amy amy
define f.15 amy list amy amy
unary? f.1
unary? f.2
unary? f.3
unary? f.4
unary? f.5
unary? f.6
unary? f.7
unary? f.8
unary? f.9
unary? f.10
unary? f.11
unary? f.12
unary? f.13
unary? f.14
unary? f.15
binary? f.1
binary? f.2
binary? f.3
binary? f.4
binary? f.5
binary? f.6
binary? f.7
binary? f.8
binary? f.9
binary? f.10
binary? f.11
binary? f.12
binary? f.13
binary? f.14
binary? f.15
step f.1 20
step f.2 1000
step f.3 text
step f.4 list 10 15
step f.5 10 15
step f.6 10 15
step f.7 10 15
step f.8 list 10 15
step f.9 10 20
step f.10 star 10 20
step f.11 clara
step f.12 clara
step f.13 clara
step f.14 clara
step f.15 clara
;Question 3.
; The function zero? takes a number and determines whether its zero. The function positive? takes a number and determines whether its positive. ; Beside each of the following two expressions, write down its value, or the word error if it produces an error
map unary? list zero? positive?
; Assume the following definition:
define x 5
; Write out the following steps
step map zero? list x dec 1 4
map binary? list zero? positive?
step map positive? list 12×12 121 22 1
;Question 4.
; The function textlist takes a text and produces a list containing each of its characters. Beside each of these two expressions write down its value.
unary? textlist binary? textlist
; Assume the following definition:
define k cat
; For each function call below, IF IT HAS EXACTLY ONE ARGUMENT EXPRESSION, then fill in the comment beside it by writing down the type of the argument
; function, boolean, list, image, number, or text, OTHERWISE dont fill in the comment. Then write down the value of the whole function call below it, or the word error it produces an error.
textlist ok ; type of the argument:textlist o k ; type of the argument:textlist list o k ; type of the argument:textlist ; type of the argument:
textlist; type of the argument:
; Write out the following steps
step same? length textlist k textlength k
step same? length textlist ! textlength !
textlist k ; type of the argument:
textlist k ; type of the argument:
textlist list doge ; type of the argument:textlist d o g e ; type of the argument:textlist list d o g e ; type of the argument:
step same? length textlist kitty textlength kitty
step same? length textlisttextlength
Reviews
There are no reviews yet.