Consider the following definition written in Cinnameg.
Define f(n) = (:n*n :: f(n+1):).What value does expression f(2) compute? Give the full value, as it would be if it were examined. (It suffices to give a clear description of the full value.) Evaluating a promise does not change the value that is represented, it only changes the representation of the value.
Consider the following definition written in Cinnameg.
Define f(n) = (: n :: f(n*n) :).What value does expression f(2) compute? Give the full value, as it would be if it were examined.
Write an equational definition of rfold(i, f, L) so that rfold(i, f, [a,b,c]) = f (a, f (b, f (c, i))). Generalize to an arbitrarily long list.
To get a better understanding of this, suppose that the function (f ) is a binary operator * (whose meaning could be anything), where operator * is right-associative. That is, a*b*c means a*(b*c). Then rfold(i, *, [a,b,c]) = a*b*c*i and rfold(x, *, [a,b,c,d]) = a*b*c*d*x.
By definition, rfold(i, f, [ ]) = i.
What is the significance of λ-calculus to the semantics of programming languages?
If you perform a single β-reduction on (λx.λy.y x)(w z), what do you get?
If you perform a single β-reduction on expression (λx.λy.x x y) (λz.z z), what do you get?
A combinator is a term of λ-calculus that has no free variables. Which of the following are combinators?
If you perform a single β-reduction on (λx.x x)(λx.x x), what do you get?
Suppose that spread(x) takes a list x and yields another list that contains all members of x with a 1 after it. For example,
Write a definition of spread(x) in Cinnameg that only computes as much of the result list as is needed by the program.