File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
+ } ) ;
You can’t perform that action at this time.
0 commit comments