fn eval(expr: &Expr, subs: &Vec<Value>, funcs: &HashMap<String, Rc<Func>>) -> Value {
    use self::types::Expr::*;
    match *expr {
        Var(var) => subs[var as usize].clone(),
        Val(ref val) => val.clone(),
        App(ref fun_name, ref args) => {
            let arg_vals: Vec<Value> = args.iter()
                .map(|arg_expr| eval(arg_expr, subs, funcs))
                .collect();
            let arg = if arg_vals.len() == 1 {
                arg_vals[0].clone()
            } else {
                values::Tuple::new(arg_vals) as Value
            };
            (funcs[fun_name].run)(arg)
        }
    }
}
// Evaluates an expression, given a set of bindings to variables
Evaluates an expression, given a set of bindings to variables
Evaluates an expression given a set of bindings to variables
fn eval(expr: &Expr, subs: &Vec<Value>, funcs: &HashMap<String, Rc<Func>>) -> Value {
    use self::types::Expr::*;
    match *expr {
        Var(var) => subs[var as usize].clone(),
        Val(ref val) => val.clone(),
        App(ref fun_name, ref args) => {
            let arg_vals: Vec<Value> = args.iter()
                .map(|arg_expr| eval(arg_expr, subs, funcs))
                .collect();
            let arg = if arg_vals.len() == 1 {
                arg_vals[0].clone()
            } else {
                values::Tuple::new(arg_vals) as Value
            };
            (funcs[fun_name].run)(arg)
        }
    }
}
fn eval ( expr : & Expr , subs : & Vec < Value > , funcs : & HashMap < String , Rc < Func > > ) -> Value { use self :: types :: Expr :: * ; match * expr { Var ( var ) => subs [ var as usize ] . clone ( ) , Val ( ref val ) => val . clone ( ) , App ( ref fun_name , ref args ) => { let arg_vals : Vec < Value > = args . iter ( ) . map ( | arg_expr | eval ( arg_expr , subs , funcs ) ) . collect ( ) ; let arg = if arg_vals . len ( ) == 1 { arg_vals [ 0 ] . clone ( ) } else { values :: Tuple :: new ( arg_vals ) as Value } ; ( funcs [ fun_name ] . run ) ( arg ) } } }
Evaluates an expression, given a set of bindings to variables
Evaluates an expression given a set of bindings to variables
expr
&Expr
subs
&Vec<Value>
funcs
&HashMap<String, Rc<Func>>
expr
&Expr
subs
&Vec<Value>
funcs
&HashMap<String, Rc<Func>>