Skip to content

Commit 30d9648

Browse files
committed
Copy example under /workspace for easier testing
Run `npx mocha` to test without container.
1 parent 28aeb43 commit 30d9648

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

workspace/solution.lc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Kacarott
2+
3+
true = \ a b . a
4+
false = \ a b . b
5+
%invalid = \a b . b
6+
7+
zero = false
8+
succ = \ n f x . f (n f x)
9+
10+
y = \ f . (\ x . f (x x)) (\ x . f (x x))
11+
12+
counter = y (\ count n b . b (count (succ n)) (n) ) zero

workspace/test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { assert, config as chaiConfig } from "chai";
2+
chaiConfig.truncateThreshold = 0;
3+
4+
import * as LC from "@codewars/lambda-calculus";
5+
import { solution } from "./files.js"; // /workspace/files.js
6+
7+
LC.config.purity = "Let";
8+
LC.config.numEncoding = "Church";
9+
const toInt = LC.toIntWith(LC.config);
10+
const { counter } = LC.compile(solution());
11+
12+
const T = t => _ => t;
13+
const F = _ => f => f;
14+
15+
describe("counter", () => {
16+
it("fixed tests", () => {
17+
assert.strictEqual(toInt(counter(T)(T)(T)(F)), 3);
18+
assert.strictEqual(toInt(counter(T)(F)), 1);
19+
assert.strictEqual(toInt(counter(T)(T)(T)(T)(T)(T)(T)(F)), 7);
20+
});
21+
});

0 commit comments

Comments
 (0)