Index: polemy/eval.d ================================================================== --- polemy/eval.d +++ polemy/eval.d @@ -45,10 +45,26 @@ throw new PolemyRuntimeException("/ takes two arguments!! ["~to!string(pos)~"]"); if( auto x = cast(IntValue)args[0] ) if( auto y = cast(IntValue)args[1] ) return new IntValue(x.data/y.data); throw new PolemyRuntimeException("cannot add non-integers ["~to!string(pos)~"]"); + })); + ctx.add("<", new FunValue(delegate Value(immutable LexPosition pos, Value[] args){ + if( args.length != 2 ) + throw new PolemyRuntimeException("< takes two arguments!! ["~to!string(pos)~"]"); + if( auto x = cast(IntValue)args[0] ) + if( auto y = cast(IntValue)args[1] ) + return new IntValue(BigInt(to!int(x.data < y.data))); + throw new PolemyRuntimeException("cannot add non-integers ["~to!string(pos)~"]"); + })); + ctx.add(">", new FunValue(delegate Value(immutable LexPosition pos, Value[] args){ + if( args.length != 2 ) + throw new PolemyRuntimeException("> takes two arguments!! ["~to!string(pos)~"]"); + if( auto x = cast(IntValue)args[0] ) + if( auto y = cast(IntValue)args[1] ) + return new IntValue(BigInt(to!int(x.data>y.data))); + throw new PolemyRuntimeException("cannot add non-integers ["~to!string(pos)~"]"); })); ctx.add("print", new FunValue(delegate Value(immutable LexPosition pos, Value[] args){ foreach(a; args) write(a); writeln(""); @@ -203,6 +219,13 @@ { x*fac(x-1); } else { 1; }; }; print(fac(10));`); + evalString(`var fib = fun(x){ + if(x<2) + { 1; } + else + { fib(x-1) + fib(x-2); }; + }; + print(fib(10));`); }