Люблю, когда
сложные вещи растолковывают простым
языком.
Где-то я читал,
что только очень хороший учитель в
состоянии разъяснить ученику сложные
вещи простыми словами. Что-то в этом
роде.
Higher-Order
functions are functions that either accept a function in the
parameter list, returns a parameter, or does both. First Class
functions always do both; they accept functions as arguments and
return functions
…
a pure function
doesn’t need to accept or return a function. It doesn’t need to
even have a parameter list.
Pure functions do
require you to return something, though. Pure functions are functions
that fit both of these statements:
-- When called
with the same arguments, it always returns the same result. Not
returning anything does not count as “returning the same result”,
because having a function that doesn’t return anything doesn’t
follow the next statement.
-- There are no
side effects, nothing mutated
…
One thing to note
about lambdas is that they’re anonymous. They have no name.
They can be assigned to a variable with a name, but that doesn’t
stop them from being lambdas. They’re a shorthand version of a
function declaration, often called “function literals”; a name is
not part of that declaration
…
Anyway, currying
allows you to partially supply parameters to a function so it can
finish being filled in later. This is the same purpose that partial
fulfills in Python. Some languages use this as the only way to define
functions that take multiple parameters. Passing in the first
argument returns the function that will taking in the second
argument, all the way until you’ve given the final argument, where
it applies all the arguments to the function
original post http://vasnake.blogspot.com/2015/04/functions.html
Комментариев нет:
Отправить комментарий