Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@codewars/lambda-calculus

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codewars/lambda-calculus

Lambda Calculus evaluator for Codewars

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
increased by200%
Maintainers
1
Weekly downloads
 
Created
Source

LC Compiler for Codewars

logo-black logo-white

Written by Kacarott and JohanWiltink

Install

$ npm i --save @codewars/lambda-calculus

Usage

NOTE: When writing tests on Codewars, you can use the predefined wrapper module "./files.js" to get the solution file instead of using fs like below.

import { readFileSync } from "fs";
// Import module
import * as LC from "@codewars/lambda-calculus";

// Set config options
LC.config.purity = "Let";
LC.config.numEncoding = "Church";

const code = readFileSync("solution.lc", {encoding: "utf8"});
// Compile
const solution = compile(code).TRUE;
// or
const {TRUE,FALSE} = compile(code);

// Use
console.log(solution(true)(false)); // true
// or
console.log(TRUE(true)(false)) // true

Documentation


compile :: String -> {String: (Term -> Term)}

compile is the main entry point of the module. Compiles the specified text according the current config options, and returns an object binding all defined terms to their corresponding functions.


config :: {String: String}

config is an object which provides the interface for controlling how compilation behaves. Currently there are three configurable properties: purity, numEncoding and verbosity.

PropertyOptionDescription
purityLetAllows definition of named terms which can be used in subsequent definitions. Does not support recursion.
LetRecThe same as Let, but additionally supporting direct recursion.
PureLC (default)Pure lambda calculus only. Terms are still named so that they can be accessed by tests, but named terms may not be used elsewhere.
numEncodingNoneNo number encoding. Use of number literals will cause an error.
Church
Scott
BinaryScott
Number literals will be automatically converted to corresponding LC terms, according to the encoding chosen.
verbosityCalm
Concise
Loquacious
Verbose
Controls the amount of information that will be reported during compilation.

Container Image

The container image used by the Code Runner is available on GHCR.

docker pull ghcr.io/codewars/lambda-calculus:latest
Building

The image can be built from this repository:

docker build -t ghcr.io/codewars/lambda-calculus:latest .
Usage

See example/ to learn how to use the image to test locally.

Keywords

FAQs

Package last updated on 05 Feb 2024

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