A zero-argument function used to delay evaluation is called a thunk. – As a verb: thunk the expression. This works (but it is silly to wrap if like this): 3. (define (my-if x y z)
Simply so, what is apply in Racket?
racket Functions The `apply` function
The major advantage of apply is that it works on arbitrary computed lists, including appended lists and lists that come from function arguments.
Subsequently, what is curry in Racket?
racket Higher Order Functions Curry
curryr can be used when the arguments need to be inserted at the end. In other words, (curryr list 1 2) will produce a function expecting some new-arguments … . When called, that new function will in turn call (list new-arguments … 1 2) .
Why is it called a thunk?
In computer programming, a thunk is a subroutine used to inject a calculation into another subroutine. … The term originated as a whimsical irregular form of “think.” It refers to the original use of thunks in ALGOL compilers, which required special analysis (thought) to determine what type of routine to generate.
In Racket (and other functional programming languages) lambda s are very useful, when you want to pass an in-line, one-shot function as a parameter without defining it first. For example, suppose that we want to square a list of numbers.
Local Binding: let, let*, letrec, … in The Racket Reference also documents let. A let form binds a set of identifiers, each to the result of some expression, for use in the let body: (let ([id expr] …) body …+)
Begin takes an arbitrary number of expressions and executes each one of them but only returns the result of the last expression in the body. https://stackoverflow.com/questions/29382733/racket-begin-form/29387064#29387064.
Symbols in The Racket Guide introduces symbols. A symbol is like an immutable string, but symbols are normally interned, so that two symbols with the same character content are normally eq?. All symbols produced by the default reader (see Reading Symbols) are interned.
Recursion is a favored technique in functional programming because it helps avoid mutation of values.
The list is the fundamental data structure of Racket. A list is a sequence of values. A list can contain any kind of value, including other lists. A list can contain any number of values.