Skip to main content
Module

x/fun/array.ts>traverse

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Latest
function traverse
import { traverse } from "https://deno.land/x/fun@v2.0.0/array.ts";

Traverse a ReadonlyArray using an Applicable over V and a mapping function A => V.

Examples

Example 1

import * as A from "./array.ts";
import { pipe, identity } from "./fn.ts";

const traverse = A.traverse(A.ApplicableArray);

const result = pipe(
  [[1, 2], [3, 4]],
  traverse(identity),
); // [[1, 3], [1, 4], [2, 3], [2, 4]]

Returns

<A, I, J = never, K = never, L = unknown, M = unknown>(favi: (a: A, i: number) => $<V, [I, J, K], [L], [M]>) => (ua: ReadonlyArray<A>) => $<V, [ReadonlyArray<I>, J, K], [L], [M]>