Update explanations
Update explanation in digitize Update explanation in delay Update explanation in curry Update explanation in compose_right Update explanation in compose
This commit is contained in:
@ -5,7 +5,7 @@ tags: function,intermediate
|
|||||||
|
|
||||||
Performs right-to-left function composition.
|
Performs right-to-left function composition.
|
||||||
|
|
||||||
Use `reduce()` to perform right-to-left function composition.
|
Use `functools.reduce()` to perform right-to-left function composition.
|
||||||
The last (rightmost) function can accept one or more arguments; the remaining functions must be unary.
|
The last (rightmost) function can accept one or more arguments; the remaining functions must be unary.
|
||||||
|
|
||||||
```py
|
```py
|
||||||
|
|||||||
@ -5,7 +5,7 @@ tags: function,intermediate
|
|||||||
|
|
||||||
Performs left-to-right function composition.
|
Performs left-to-right function composition.
|
||||||
|
|
||||||
Use `reduce()` to perform left-to-right function composition.
|
Use `functools.reduce()` to perform left-to-right function composition.
|
||||||
The first (leftmost) function can accept one or more arguments; the remaining functions must be unary.
|
The first (leftmost) function can accept one or more arguments; the remaining functions must be unary.
|
||||||
|
|
||||||
```py
|
```py
|
||||||
|
|||||||
@ -5,7 +5,7 @@ tags: function,intermediate
|
|||||||
|
|
||||||
Curries a function.
|
Curries a function.
|
||||||
|
|
||||||
Use `partial()` to return a new partial object which behaves like `fn` with the given arguments, `args`, partially applied.
|
Use `functools.partial()` to return a new partial object which behaves like `fn` with the given arguments, `args`, partially applied.
|
||||||
|
|
||||||
```py
|
```py
|
||||||
from functools import partial
|
from functools import partial
|
||||||
@ -16,7 +16,7 @@ def curry(fn, *args):
|
|||||||
|
|
||||||
```py
|
```py
|
||||||
add = lambda x, y: x + y
|
add = lambda x, y: x + y
|
||||||
add10 = curry(sum, 10)
|
add10 = curry(add, 10)
|
||||||
|
|
||||||
add10(20) # 30
|
add10(20) # 30
|
||||||
```
|
```
|
||||||
|
|||||||
@ -5,7 +5,7 @@ tags: function,intermediate
|
|||||||
|
|
||||||
Invokes the provided function after `ms` milliseconds.
|
Invokes the provided function after `ms` milliseconds.
|
||||||
|
|
||||||
Use `sleep()` to delay the execution of `fn` by `ms / 1000` seconds.
|
Use `time.sleep()` to delay the execution of `fn` by `ms / 1000` seconds.
|
||||||
|
|
||||||
```py
|
```py
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|||||||
@ -3,7 +3,7 @@ title: digitize
|
|||||||
tags: math,list,beginner
|
tags: math,list,beginner
|
||||||
---
|
---
|
||||||
|
|
||||||
Converts a number to an array of digits.
|
Converts a number to a list of digits.
|
||||||
|
|
||||||
Use `map()` combined with `int` on the string representation of `n` and return a list from the result.
|
Use `map()` combined with `int` on the string representation of `n` and return a list from the result.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user