Generate a sequence with a recurrent relationship by applying a function to the previous state. Similar to accumulate but generates a new sequence from scratch.
import { pipe } from "yta";import { map, recurrent, take, toArray } from "yta/async";await pipe( recurrent(([a, b]) => [b, a + b], [0, 1]), take(11), map(([a]) => a), toArray(),);// => [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55] Copy
import { pipe } from "yta";import { map, recurrent, take, toArray } from "yta/async";await pipe( recurrent(([a, b]) => [b, a + b], [0, 1]), take(11), map(([a]) => a), toArray(),);// => [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
See also:
Generate a sequence with a recurrent relationship by applying a function to the previous state. Similar to accumulate but generates a new sequence from scratch.
See also: