npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@codewars/lambda-calculus

v1.1.0

Published

Lambda Calculus evaluator for Codewars

Downloads

29

Readme

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.

| Property | Option | Description | | -------- | ---- | ---- | | purity | Let | Allows definition of named terms which can be used in subsequent definitions. Does not support recursion. | | | LetRec | The 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. | | numEncoding | None | No number encoding. Use of number literals will cause an error. | | | ChurchScottBinaryScott | Number literals will be automatically converted to corresponding LC terms, according to the encoding chosen. | | verbosity | CalmConciseLoquaciousVerbose | 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.