Launch Week Day 2: Introducing Reports: An Extensible Reporting Framework for Socket Data.Learn More
Socket
Book a DemoSign in
Socket

variadic-y

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

variadic-y

Variadic y-combinator for recursive anonymous functions

latest
npmnpm
Version
2.0.1
Version published
Maintainers
1
Created
Source

variadic-y

build coverage vulnerabilities dependencies devDependencies

Variadic y-combinator for recursive anonymous functions.

Installation

npm i variadic-y

Usage

Define your recursive function to take in a reference to itself. Here, f.

import { Y } from "variadic-y";

Y(f => (x, y = 1) => (x == 1 ? y : f(x - 1, x * y)))(5); // 120

Design

Unmemoized to enable usage with objects and referentially opaque functions.

export const Y = (a: any) =>
  ((b: any) => a((...c: any[]) => b(b)(...c)))((b: any) =>
    a((...c: any[]) => b(b)(...c))
  );

If anyone knows how to properly type this combinator in TypeScript, let me know.

Keywords

combinators

FAQs

Package last updated on 17 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts