Skip to content

Commit d4c8ded

Browse files
authoredFeb 13, 2022
Merge pull request #55 from codewars/update-image
·
v1.1.0v1.0.0-rc.3
2 parents da54249 + 30d9648 commit d4c8ded

File tree

4 files changed

+43
-10
lines changed

4 files changed

+43
-10
lines changed
 

‎workspace/package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎workspace/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"timeout": 0
1212
},
1313
"dependencies": {
14-
"@codewars/lambda-calculus": "^1.0.0-rc.1"
14+
"@codewars/lambda-calculus": "^1.0.0-rc.2"
1515
},
1616
"devDependencies": {
1717
"@codewars/mocha-reporter": "^1.0.0",

‎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)
Please sign in to comment.