Question 1 @ 2022-02-01 19:04
Which topic is going to be the most important for in this class?
- Interpretation
- Syntax
- Idioms
- Semantics
- Libraries (and Runtime)
- Interpreters vs Compilers
Question 2 @ 2022-02-01 19:07
What makes the below code “bad style”?
(define (how-many a b c)
(cond [(> (* b b) (* 4 a c)) 2]
[(= (* b b) (* 4 a c)) 1]
[(< (* b b) (* 4 a c)) 0]))
- It’s too slow since it repeats computations.
- It’s too verbose since it repeats expressions.
- It’s using square brackets in a non-idiomatic way.
- Tail-recursion should not be used here.
- It should be using an
else
.
- It’s numerically incorrect.
Question 3 @ 2022-02-01 19:11
Tail-call elimination optimizes code in which of the following ways?
- Makes the semantics simpler
- Improves time complexity (runtime)
- Improves space complexity (space)
- Improves style by being more idiomatic Racket
Question 4 @ 2022-02-01 19:13
What is the purpose of the Backus-Naur Form (BNF)?
- Explore new algorithms
- Specify a grammar
- String manipulations
- Stylistic purposes
Question 5 @ 2022-02-01 19:14
What is the difference between the match
form and the cases
form?
-
match
is for bindings; cases
is for assignment
- Different syntactic sugar
-
match
is for primitive values, cases
is for lists
-
match
is for primitive values; cases
is for user-defined types
- There is no difference between them,
match
is just a legacy form