• Concatenates two trees.

    Type Parameters

    • A

    Parameters

    Returns ((right) => FingerTree<A>)

    The concatenated tree.

    Examples

    import { concat, empty, fromArray, reduceTree } from "./finger-tree.ts";
    import * as Array from "../array.ts";
    import { assertEquals } from "../../deps.ts";

    const toArray = Array.fromReduce(reduceTree);

    const emptiness = empty;
    const single = fromArray([3]);
    const many = fromArray([2, 1, 8, 2, 8]);

    assertEquals(toArray(concat(emptiness)(emptiness)), []);

    assertEquals(toArray(concat(emptiness)(single)), [3]);
    assertEquals(toArray(concat(single)(emptiness)), [3]);

    assertEquals(toArray(concat(single)(single)), [3, 3]);

    assertEquals(toArray(concat(emptiness)(many)), [2, 1, 8, 2, 8]);
    assertEquals(toArray(concat(many)(emptiness)), [2, 1, 8, 2, 8]);

    assertEquals(toArray(concat(single)(many)), [3, 2, 1, 8, 2, 8]);
    assertEquals(toArray(concat(many)(single)), [2, 1, 8, 2, 8, 3]);

    assertEquals(toArray(concat(many)(many)), [
    2,
    1,
    8,
    2,
    8,
    2,
    1,
    8,
    2,
    8,
    ]);

Generated using TypeDoc