pub fn apply(&mut self, args:&Data) -> Data {
        match *self {
            Function{ args: ref params, ref body, ref mut env } => {
                if params.len() == args.len() {
                    let mut scope = Env::new(env.clone());
                    let mut a = (**params).clone();
                    let mut b = (*args).clone();
                    while a.car() != Nil && b.car() != Nil {
                        match a.car() {
                            Symbol(ref s) => scope.insert(s.clone(), b.car().clone()),
                            _ => unreachable!("In apply"),
                        }
                        a = a.cdr();
                        b = b.cdr();
                    }

                    body.eval(&mut scope)
                }
                else { panic!("Arity mismatch. Needed {}, but called with {}",
                              params.len(), args.len()); }
            },

            PrimitiveFn(ref s) => {
                let f = PRIMITIVES.get(s).unwrap();
                return f(args)
            }

            _ => panic!("{} is not a function."),
        }
    }
/// Applies a function to a list of arguments.
Applies a function to a list of arguments.
Applies a function to a list of arguments .
pub fn apply(&mut self, args:&Data) -> Data {
        match *self {
            Function{ args: ref params, ref body, ref mut env } => {
                if params.len() == args.len() {
                    let mut scope = Env::new(env.clone());
                    let mut a = (**params).clone();
                    let mut b = (*args).clone();
                    while a.car() != Nil && b.car() != Nil {
                        match a.car() {
                            Symbol(ref s) => scope.insert(s.clone(), b.car().clone()),
                            _ => unreachable!("In apply"),
                        }
                        a = a.cdr();
                        b = b.cdr();
                    }
                    body.eval(&mut scope)
                }
                else { panic!("Arity mismatch. Needed {}, but called with {}",
                              params.len(), args.len()); }
            },
            PrimitiveFn(ref s) => {
                let f = PRIMITIVES.get(s).unwrap();
                return f(args)
            }
            _ => panic!("{} is not a function."),
        }
    }
pub fn apply ( & mut self , args : & Data ) -> Data { match * self { Function { args : ref params , ref body , ref mut env } => { if params . len ( ) == args . len ( ) { let mut scope = Env :: new ( env . clone ( ) ) ; let mut a = ( * * params ) . clone ( ) ; let mut b = ( * args ) . clone ( ) ; while a . car ( ) != Nil && b . car ( ) != Nil { match a . car ( ) { Symbol ( ref s ) => scope . insert ( s . clone ( ) , b . car ( ) . clone ( ) ) , _ => unreachable ! ( " " ) , } a = a . cdr ( ) ; b = b . cdr ( ) ; } body . eval ( & mut scope ) } else { panic ! ( " " params len ( ) args len ( ) ) ; } } , PrimitiveFn ( ref s ) => { let f = PRIMITIVES . get ( s ) . unwrap ( ) ; return f ( args ) } _ => panic ! ( " " ) , } }
Applies a function to a list of arguments.
Applies a function to a list of arguments .
&mut self
args
&Data