File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11all : compile.js
22 npm install
33 node lambda -h
4- node lambda -e " (x, y, z: x z (y z)) hello bye world"
4+ node lambda -ce " S hello bye world"
55 node lambda -d debug.mlc
66 node lambda -pt fact.mlc
77
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ This package provides a `lambda` command with the following interface:
99Usage: lambda [options] (<file> | -e <expr>)
1010
1111Options:
12+ --comb, -c Predefine commonly used combinators [boolean]
1213 --term, -t Output the term being evaluated [boolean]
1314 --perf, -p Print benchmarks [boolean]
1415 --expr, -e Process the argument as expression [boolean]
Original file line number Diff line number Diff line change 1+ I = x: x;
2+ K = x, y: x;
3+ S = x, y, z: x z (y z);
4+ T = K;
5+ F = x, y: y;
6+ AND = p, q: p q F;
7+ OR = p, q: p T q;
8+ NOT = p: (a, b: p b a);
9+ C0 = f, x: x;
10+ C1 = f, x: f x;
11+ C2 = f, x: f (f x);
12+ C3 = f, x: f (f (f x));
13+ C4 = f, x: f (f (f (f x)));
14+ C5 = f, x: f (f (f (f (f x))));
15+ C6 = f, x: f (f (f (f (f (f x)))));
16+ C7 = f, x: f (f (f (f (f (f (f x))))));
17+ C8 = f, x: f (f (f (f (f (f (f (f x)))))));
18+ C9 = f, x: f (f (f (f (f (f (f (f (f x))))))));
19+ C10 = f, x: f (f (f (f (f (f (f (f (f (f x)))))))));
20+ SUCC = n: (f, x: f (n f x));
21+ PLUS = m, n: (f, x: m f (n f x));
22+ MULT = m, n: (f: m (n f));
23+ EXP = m, n: n m;
24+ PRED = n: (f, x: n (g, h: h (g f)) (K x) I);
25+ MINUS = m, n: n PRED m;
26+ ZERO = n: n (K F) T;
27+ A = self, f: f (self self f);
28+ Y = A A;
Original file line number Diff line number Diff line change 22
33var lambda = require ( "." ) ;
44var yargs = require ( "yargs" ) ;
5+ var path = require ( "path" ) ;
56var fs = require ( "fs" ) ;
67
78var opts = {
9+ comb : {
10+ alias : "c" ,
11+ desc : "Predefine commonly used combinators" ,
12+ boolean : true
13+ } ,
814 term : {
915 alias : "t" ,
1016 desc : "Output the term being evaluated" ,
@@ -44,18 +50,22 @@ var argv = yargs
4450 . wrap ( 70 )
4551 . argv ;
4652
53+ var comb = fs . readFileSync ( path . join ( __dirname , "helper.txt" ) , "utf8" ) ;
4754var input = argv . _ [ 0 ] ;
4855
4956if ( ! argv . expr )
5057 input = fs . readFileSync ( input , "utf8" ) ;
5158
59+ if ( argv . comb )
60+ input = comb . concat ( input ) ;
61+
5262if ( argv . debug ) {
5363 var eqn ;
5464
5565 lambda . prepare ( input ) ;
5666
5767 while ( eqn = lambda . debug1 ( ) )
58- console . log ( eqn ) ;
68+ console . info ( eqn ) ;
5969} else {
6070 var output = lambda ( input ) ;
6171 var stats = JSON . stringify ( output . stats , null , "\t" ) ;
You can’t perform that action at this time.
0 commit comments