Questions and CORRECT Answers
Functional programming languages do NOT allow us to define - CORRECT ANSWER -
variables whose value can be modified.
Which of the following is a valid Scheme expression? - CORRECT ANSWER - (* 9 (/ (- 4 2)
7)) paren always around symbols
In Scheme, the form (symbol-length? 'James) will return: - CORRECT ANSWER - an error
message
Convert the following expression into prefix-p notation (a Scheme statement):
-5 * (2 + 1/2) + 40 - CORRECT ANSWER - (+ (* (- 5) (+ 2 (/ 1 2))) 40)
The statement "a function is a first-class object" means that a function - CORRECT
ANSWER - can be placed in a place where a value is expected.
What notation requires parentheses in order to correctly define the order of computation? -
CORRECT ANSWER - infix notation
Convert the following expression into prefix-p notation (a Scheme statement):
10 + (5 - 3) + - CORRECT ANSWER - (+ 10 (- 5 3) (/ 2 4))
Which of the following expression will return false (#f)? - CORRECT ANSWER - (number?
#\7)
, The Scheme form (char? #\5) will return - CORRECT ANSWER - true (#t)
How would Scheme implement a function such as: for (i = 1; i< 100, i++) {sum = sum + i;} -
CORRECT ANSWER - With recursion.
A student is wondering if Scheme is a strong or weakly typed language. How might they check
this? Select all that apply - CORRECT ANSWER - They could execute a form like (+ #\a 10)
in the REPL. If it works (like in C), then it is probably weakly typed.
What data structure is used in Scheme for representing extremely large integers? - CORRECT
ANSWER - probably a list. Really: we shouldn't know or care.
Given an expression: x1 + x2 + x3 + x4
Which language allows us to evaluate the expression in this order: (1) x1 plus x2; (2) x3 plus x4;
(3) sum of ( x1 + x2 ) plus sum of ( x3 + x4 ), without concern for producing a different result
than other evaluation orders: - CORRECT ANSWER - Scheme
Given this procedure, what is the return result?(define (guess value) (cond ((number? value) "I'm
a number") ((char? value) "I'm a character") ((integer? value) "I'm a integer")))
(guess 10) - CORRECT ANSWER - "I'm a number"
What statements contain non-functional features of Scheme? Select all that apply. - CORRECT
ANSWER - (begin (write x) x)
(display x)
A let-form in Scheme defines a set of - CORRECT ANSWER - local names.
What functional feature does the code below best exhibit?