#python #sicp
We can use higher-order functions to convert a function that takes multiple
arguments into a chain of functions that each take a single argument. More
specifically, given a function f(x, y) , we can define a function g such
that g(x)(y) is equivalent to f(x, y) . Here, g is a higher-order
function that takes in a single argument x and returns another function
that takes in a single argument y . This transformation is called currying.
If you want to change selection, open document below and click on "Move attachment"
1.6 Higher-Order Functionsd is a powerful general computational method for
solving differentiable equations. Very fast algorithms for logarithms and large
integer division employ variants of the technique in modern computers.
1.6.6 Currying
Video:
Show
Hide <span>We can use higher-order functions to convert a function that takes multiple
arguments into a chain of functions that each take a single argument. More
specifically, given a function f(x, y) , we can define a function g such
that g(x)(y) is equivalent to f(x, y) . Here, g is a higher-order
function that takes in a single argument x and returns another function
that takes in a single argument y . This transformation is called currying.
As an example, we can define a curried version of the pow function:
>>> def curried_pow(x):
def h(y):
return pow(x, y)
return h
>>&g Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details