@@ -19,7 +19,7 @@ LC.configure({ purity: "LetRec", numEncoding: { fromInt, toInt } });
19
19
20
20
const solutionText = readFileSync ( new URL ( "./solution.lc" , import . meta. url ) , { encoding : "utf8" } ) ;
21
21
const solution = LC . compile ( solutionText ) ;
22
- const { succ, pred, add, negate, sub, zero, lt0, le0, ge0, gt0, compare } = solution ;
22
+ const { succ, pred, add, mul , negate, sub, dbl , zero, lt0, le0, ge0, gt0, compare } = solution ;
23
23
24
24
const toBoolean = p => p ( true ) ( false ) ;
25
25
const toOrdering = cmp => cmp ( "LT" ) ( "EQ" ) ( "GT" ) ;
@@ -43,6 +43,11 @@ describe("NegaBinaryScott", () => {
43
43
for ( let n = - 10 ; n <= 10 ; n ++ )
44
44
assert . strictEqual ( toInt ( add ( m ) ( n ) ) , m + n , `add ${ m } ${ n } ` ) ;
45
45
} ) ;
46
+ it ( "mul" , ( ) => {
47
+ for ( let m = - 10 ; m <= 10 ; m ++ )
48
+ for ( let n = - 10 ; n <= 10 ; n ++ )
49
+ assert . strictEqual ( toInt ( mul ( m ) ( n ) ) , m * n , `mul ${ m } ${ n } ` ) ;
50
+ } ) ;
46
51
it ( "negate" , ( ) => {
47
52
for ( let n = - 10 ; n <= 10 ; n ++ )
48
53
assert . strictEqual ( toInt ( negate ( n ) ) , - n , `negate ${ n } ` ) ;
@@ -56,6 +61,10 @@ describe("NegaBinaryScott", () => {
56
61
for ( let n = - 10 ; n <= 10 ; n ++ )
57
62
assert . strictEqual ( toInt ( sub ( m ) ( n ) ) , m - n , `sub ${ m } ${ n } ` ) ;
58
63
} ) ;
64
+ it ( "dbl" , ( ) => {
65
+ for ( let n = - 10 ; n <= 10 ; n ++ )
66
+ assert . strictEqual ( toInt ( dbl ( n ) ) , 2 * n , `dbl ${ n } ` ) ;
67
+ } ) ;
59
68
it ( "eq, uneq" , ( ) => {
60
69
for ( let n = - 10 ; n <= 10 ; n ++ )
61
70
assert . strictEqual ( toBoolean ( zero ( n ) ) , n === 0 , `zero ${ n } ` ) ,
0 commit comments