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 currying.
Tags
#python #sicp
Question
Why is currying?
Answer
?
Tags
#python #sicp
Question
Why is currying?
Answer
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 currying.
If you want to change selection, open original toplevel document below and click on "Move attachment"
Parent (intermediate) annotation
Open it 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.
Original toplevel document
1.6 Higher-Order Functions d 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 learned
measured difficulty
37% [default]
last interval [days]
repetition number in this series
0
memorised on
scheduled repetition
scheduled repetition interval
last repetition or drill
Details
No repetitions
Discussion
Do you want to join discussion? Click here to log in or create user.