Basically, functional programming has functions that are similar to mathematical functions, as in
we have an
input which will give us a specific output. It does not concern side-effects, changing the state or
properties
of data but instead merely produces a separate result. - ANS-In short, how is the functional
programming paradigm different from the imperative programming
paradigm?
Head is the first element of the list, tail is the rest of the list. - ANS-What is meant by the head
and tail of a list?
A predicate is a function that returns true or false. any (example function) is true if there is a
term X
in the list such that P(X) is true. - ANS-What is meant by a predicate?
The number of parameters to a function. - ANS-What is meant by arity?
Takes a function as an argument, for example foldl. Can also be something that returns a
function as
its result. - ANS-What is meant by a higher order function?
A function that is not bound to an identifier. - ANS-What is meant by an anonymous function?
They are often used as arguments to higher order functions. - ANS-How does anonymous
functions relate to higher order functions?
map: Applies a function to every element in a list.
filter: Takes a predicate, a list and returns a list of all elements that satisfy the predicate.
zip: Combines two lists (for examples containing x's and y's) into a list containing tuples where
the first
tuple contains (x1,y1).
fold: Takes a function, accumulator and a list. Applies the function between each element of the
list
and stores the result in the accumulator. - ANS-Four common operations on lists are: map, filter,
zip, and fold. In brief, describe these operations.
A function calls upon itself inside it. - ANS-In computer science, what is meant by recursion?