https://github.com/tomokimiyauci/curry
Currying and partial application utilities
https://github.com/tomokimiyauci/curry
curry currying papply partial-application partial-apply
Last synced: 19 days ago
JSON representation
Currying and partial application utilities
- Host: GitHub
- URL: https://github.com/tomokimiyauci/curry
- Owner: TomokiMiyauci
- License: mit
- Created: 2021-06-13T14:11:35.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-06-05T15:39:21.000Z (almost 2 years ago)
- Last Synced: 2025-04-06T04:07:48.114Z (23 days ago)
- Topics: curry, currying, papply, partial-application, partial-apply
- Language: TypeScript
- Homepage:
- Size: 160 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# curry
[](https://deno.land/x/curry)
[](https://doc.deno.land/https/deno.land/x/curry/mod.ts)
[](https://github.com/TomokiMiyauci/curry/releases)
[](https://codecov.io/gh/TomokiMiyauci/curry)
[](https://github.com/TomokiMiyauci/curry/blob/main/LICENSE)[](https://github.com/TomokiMiyauci/curry/actions/workflows/test.yaml)
[](https://nodei.co/npm/@miyauci/curry/)Currying and partial application utilities.
## Currying
Provides features related to currying.
> currying is the technique of translating the evaluation of a function that
> takes multiple arguments into evaluating a sequence of functions, each with a
> single argument.### curry
[](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fcurry%2Fmod.ts&treeshake=%5B%7B+curry+%7D%5D#sharing)
`curry` returns curried function.
```ts
import { curry } from "https://deno.land/x/curry@$VERSION/mod.ts";declare const fn: (a: string, b: number, c: boolean) => void;
const curriedFn = curry(fn);curriedFn("")(0)(false);
curriedFn("", 0)(false);
curriedFn("", 0, false);
```## Partial application
Partial application refers to the process of fixing a number of arguments to a
function, producing another function of smaller arity.It has the following characteristics:
- The `length` property is not strict.
- The `name` property is `bound`.### papplyLeft
[](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fcurry%2Fmod.ts&treeshake=%5B%7B+papplyLeft+%7D%5D#sharing)
Create a bound function with arguments fixed from the left.
```ts
import { papplyLeft } from "https://deno.land/x/curry@$VERSION/mod.ts";declare const fn: (a: string, b: number, c: boolean) => void;
const ternary = papplyLeft(fn);
const binary = papplyLeft(fn, "");
const unary = papplyLeft(fn, "", 0);
const nullary = papplyLeft(fn, "", 0, false);
```### papplyRight
[](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fcurry%2Fmod.ts&treeshake=%5B%7B+partialRight+%7D%5D#sharing)
Create a bound function with arguments fixed from the right
```ts
import { papplyRight } from "https://deno.land/x/curry@$VERSION/mod.ts";declare const fn: (a: string, b: number, c: boolean) => void;
const binary = papplyRight(fn, false);
const unary = papplyRight(fn, false, 0);
const nullary = papplyRight(fn, false, 0, "");
```### papplyRest
[](https://bundlejs.com/?q=https%3A%2F%2Fdeno.land%2Fx%2Fcurry%2Fmod.ts&treeshake=%5B%7B+papplyRest+%7D%5D#sharing)
Create a bound function with fixed arguments except the first one.
```ts
import { papplyRest } from "https://deno.land/x/curry@$VERSION/mod.ts";declare const fn: (a: string, b: number, c: boolean) => void;
const binary = papplyRest(fn, 0);
const unary = papplyRest(fn, 0, false);
```## API
See [deno doc](https://deno.land/x/curry/mod.ts) for all APIs.
## License
Copyright © 2023-present [Tomoki Miyauchi](https://github.com/TomokiMiyauci).
Released under the [MIT](./LICENSE) license