An open API service indexing awesome lists of open source software.

https://github.com/samualtnorman/decurse

An abstraction over continuation-passing and trampolining to write recursive functions that don't exceed the maximum call stack size.
https://github.com/samualtnorman/decurse

abstraction call-stack callstack continuation-passing continuation-passing-style recursion trampoline uncurse

Last synced: 5 months ago
JSON representation

An abstraction over continuation-passing and trampolining to write recursive functions that don't exceed the maximum call stack size.

Awesome Lists containing this project

README

          

# Decurse
An abstraction over continuation-passing and trampolining to write recursive functions that don't exceed the maximum call stack size.

## Example
```js
import { makeDecurse } from "decurse"

const decurse = makeDecurse()

const factorial = (/** @type {bigint} */ n) => decurse(() => n
? factorial(n - 1n).then(result => result * n)
: 1n
)

factorial(100_000n).then(value => console.log(value))
```