Written by Kacarott and JohanWiltink
$ npm i --save @codewars/lambda-calculusNOTE: When writing tests on Codewars, you can use the predefined wrapper module "./files.js" to get the solution file instead of using
fslike 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)) // truecompile :: 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.
The container image used by the Code Runner is available on GHCR.
docker pull ghcr.io/codewars/lambda-calculus:latestThe image can be built from this repository:
docker build -t ghcr.io/codewars/lambda-calculus:latest .See example/ to learn how to use the image to test locally.
