Nest all content into snippets

This commit is contained in:
Angelos Chalaris
2023-05-07 16:07:29 +03:00
parent 2ecadbada9
commit 6a45d2ec07
1240 changed files with 0 additions and 0 deletions

View File

@ -0,0 +1,25 @@
---
title: Curry function
type: snippet
language: python
tags: [function]
cover: leaves-read
dateModified: 2020-11-02T19:27:07+02:00
---
Curries a function.
- Use `functools.partial()` to return a new partial object which behaves like `fn` with the given arguments, `args`, partially applied.
```py
from functools import partial
def curry(fn, *args):
return partial(fn, *args)
```
```py
add = lambda x, y: x + y
add10 = curry(add, 10)
add10(20) # 30
```