Extension methods for IronScheme

Requirements

using IronScheme;

Signatures

object Eval(this string expr, params object[] args);
object Eval(this string expr, string importspec, params object[] args);

Usage

The Eval method works very similar to string formatting. It will 'inject' the value supplied in the arguments.

var r1 = "(+ 1 2)".Eval();  // r1 is 3 

var r2 = "(+ {0} {1})".Eval(1, 2);  // r2 is 3

var myproc = "(lambda (x y) (+ x y))".Eval();
var r3 = "({0} {1} {2})".Eval(myproc, 1 , 2); // r3 is 3

"(define foo 1000)".Eval();  // executes definition in interaction environment
var r4 = "foo".Eval(); // r4 is 1000

Last edited Jul 3, 2009 at 9:29 PM by leppie, version 3

Comments

No comments yet.