What would we get if we run the following expression in our FLANG evaluator:
We’d get 5.
We’d get 6.
We’d get an error because we cannot call functions with more than one argument.
We’d get a bad syntax error, since we shouldn’t use call
for
arithmetic operators
We’d get an error when trying to bind +
since it’s a
built-in.
We’d get an error when trying to evaluate *
since it’s free.
Alice wants to map a curried version of the expt function onto a list of inputs. She first writes the function currify, which takes a two argument function and returns the curried version of the function.
She then writes a test using a curried expt
function (Racket’s
exponent):
What will be the result of this test?
It will do whatever Racket does.
It will pass, because (expt 2 3)
evaluates to 8
.
It will fail, because the map will evaluate to a list of numbers, not a single number.
It will error, because the function (currify expt)
needs to
be called on an input before it is passed into map.
It will fail, because the map will evaluate to a list of one argument functions instead.
If we drop with
from our FLANG language, would we get a weaker
language?
call
and fun
.What is a good name for the following function?
Trick question: this has free identifiers and therefore always an error.
functional-addition
compose
compose-at-point
reverse-compose
reverse-compose-at-point