Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fun/mod.ts>array.traverse

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

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]]

Type Parameters

V extends Kind

Parameters

A: Applicable<V>

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]>