Skip to main content
Module

x/fun/semigroup.ts>intercalcate

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

Create a semigroup that works like Array.join, inserting middle between every two values that are concatenated. This can have some interesting results.

Examples

Example 1

import * as SG from "./semigroup.ts";
import * as S from "./string.ts";
import { pipe } from "./fn.ts";

const { concat: toList } = pipe(
  S.SemigroupString,
  SG.intercalcate(", "),
);

const list = pipe(
  "apples",
  toList("oranges"),
  toList("and bananas"),
); // list === "apples, oranges, and bananas"

Parameters

middle: A