@@ -19,7 +19,7 @@ LC.configure({ purity: "LetRec", numEncoding: { fromInt, toInt } });
1919
2020const solutionText = readFileSync ( new URL ( "./solution.lc" , import . meta. url ) , { encoding : "utf8" } ) ;
2121const 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 ;
2323
2424const toBoolean = p => p ( true ) ( false ) ;
2525const toOrdering = cmp => cmp ( "LT" ) ( "EQ" ) ( "GT" ) ;
@@ -43,6 +43,11 @@ describe("NegaBinaryScott", () => {
4343 for ( let n = - 10 ; n <= 10 ; n ++ )
4444 assert . strictEqual ( toInt ( add ( m ) ( n ) ) , m + n , `add ${ m } ${ n } ` ) ;
4545 } ) ;
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+ } ) ;
4651 it ( "negate" , ( ) => {
4752 for ( let n = - 10 ; n <= 10 ; n ++ )
4853 assert . strictEqual ( toInt ( negate ( n ) ) , - n , `negate ${ n } ` ) ;
@@ -56,6 +61,10 @@ describe("NegaBinaryScott", () => {
5661 for ( let n = - 10 ; n <= 10 ; n ++ )
5762 assert . strictEqual ( toInt ( sub ( m ) ( n ) ) , m - n , `sub ${ m } ${ n } ` ) ;
5863 } ) ;
64+ it ( "dbl" , ( ) => {
65+ for ( let n = - 10 ; n <= 10 ; n ++ )
66+ assert . strictEqual ( toInt ( dbl ( n ) ) , 2 * n , `dbl ${ n } ` ) ;
67+ } ) ;
5968 it ( "eq, uneq" , ( ) => {
6069 for ( let n = - 10 ; n <= 10 ; n ++ )
6170 assert . strictEqual ( toBoolean ( zero ( n ) ) , n === 0 , `zero ${ n } ` ) ,
0 commit comments