Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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

  • 2.0.1
  • latest
  • npm
  • Socket score

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc