File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed
Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 1+ multiply = \ m n . n (m s ) z
Original file line number Diff line number Diff line change 1+ const { assert} = require ( "chai" ) ;
2+
3+ const LC = require ( "../../src/lambda-calculus.js" ) ;
4+ LC . config . purity = "LetRec" ;
5+ LC . config . numEncoding = "Church" ;
6+ LC . config . verbosity = "Concise" ;
7+
8+ const { multiply} = LC . compile ( ) ;
9+
10+ describe ( "Multiply" , function ( ) {
11+ it ( "example tests" , ( ) => {
12+ assert . equal ( multiply ( 7 ) ( 7 ) , 49 ) ;
13+ assert . equal ( multiply ( 11 ) ( 11 ) , 121 ) ;
14+ } ) ;
15+ it ( "random tests" , ( ) => {
16+ const rnd = ( m , n = 0 ) => Math . random ( ) * ( n - m ) + m | 0 ;
17+ for ( let i = 1 ; i <= 100 ; i ++ ) {
18+ const m = rnd ( i ) , n = rnd ( i ) ;
19+ assert . equal ( multiply ( m ) ( n ) , m * n ) ;
20+ }
21+ } ) ;
22+ } ) ;
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ const examples = [ "basics-binary-scott"
1010 , "is-prime"
1111 , "is-prime-scott"
1212 , "prime-sieve"
13+ , "multiply"
1314 ] ;
1415
1516try {
You can’t perform that action at this time.
0 commit comments