Diff
Not logged in

Differences From Artifact [70846dfa5638c8e7]:

To Artifact [5b490c90826e242f]:


43 ctx.add("/", new FunValue(delegate Value(immutable LexPosition pos, Valu 43 ctx.add("/", new FunValue(delegate Value(immutable LexPosition pos, Valu 44 if( args.length != 2 ) 44 if( args.length != 2 ) 45 throw new PolemyRuntimeException("/ takes two arguments! 45 throw new PolemyRuntimeException("/ takes two arguments! 46 if( auto x = cast(IntValue)args[0] ) 46 if( auto x = cast(IntValue)args[0] ) 47 if( auto y = cast(IntValue)args[1] ) 47 if( auto y = cast(IntValue)args[1] ) 48 return new IntValue(x.data/y.data); 48 return new IntValue(x.data/y.data); 49 throw new PolemyRuntimeException("cannot add non-integers ["~to! 49 throw new PolemyRuntimeException("cannot add non-integers ["~to! > 50 })); > 51 ctx.add("<", new FunValue(delegate Value(immutable LexPosition pos, Valu > 52 if( args.length != 2 ) > 53 throw new PolemyRuntimeException("< takes two arguments! > 54 if( auto x = cast(IntValue)args[0] ) > 55 if( auto y = cast(IntValue)args[1] ) > 56 return new IntValue(BigInt(to!int(x.data < y.dat > 57 throw new PolemyRuntimeException("cannot add non-integers ["~to! > 58 })); > 59 ctx.add(">", new FunValue(delegate Value(immutable LexPosition pos, Valu > 60 if( args.length != 2 ) > 61 throw new PolemyRuntimeException("> takes two arguments! > 62 if( auto x = cast(IntValue)args[0] ) > 63 if( auto y = cast(IntValue)args[1] ) > 64 return new IntValue(BigInt(to!int(x.data>y.data) > 65 throw new PolemyRuntimeException("cannot add non-integers ["~to! 50 })); 66 })); 51 ctx.add("print", new FunValue(delegate Value(immutable LexPosition pos, 67 ctx.add("print", new FunValue(delegate Value(immutable LexPosition pos, 52 foreach(a; args) 68 foreach(a; args) 53 write(a); 69 write(a); 54 writeln(""); 70 writeln(""); 55 return new UndefinedValue; 71 return new UndefinedValue; 56 })); 72 })); ................................................................................................................................................................................ 201 evalString(`var fac = fun(x){ 217 evalString(`var fac = fun(x){ 202 if(x) 218 if(x) 203 { x*fac(x-1); } 219 { x*fac(x-1); } 204 else 220 else 205 { 1; }; 221 { 1; }; 206 }; 222 }; 207 print(fac(10));`); 223 print(fac(10));`); > 224 evalString(`var fib = fun(x){ > 225 if(x<2) > 226 { 1; } > 227 else > 228 { fib(x-1) + fib(x-2); }; > 229 }; > 230 print(fib(10));`); 208 } 231 }