pub fn reduce(&self, args: &HashMap<u64, LambdaItem>, index: &LambdaIndex) -> LambdaItem {
        match self {
            &LambdaItem::Value(ref name) => LambdaItem::Value(name.clone()),
            &LambdaItem::Argument(id) => args.get(&id).unwrap_or(&LambdaItem::Argument(id)).clone(),
            &LambdaItem::Lambda(ref lambda) => LambdaItem::Lambda(Box::new(lambda.subst_args(args))),
            &LambdaItem::Call(ref callee, ref arg) => {
                let arg = arg.reduce(args, index);

                match callee.as_ref().reduce(args, index) {
                    LambdaItem::Value(ref name) => {
                        match index.get(name) {
                            Some(lambda) => lambda.reduce(args.clone(), Some(arg), index),
                            None => LambdaItem::Call(Box::new(LambdaItem::Value(name.clone())), Box::new(arg)),
                        }
                    }
                    LambdaItem::Argument(id) => {
                        // callee has been reduced above; this argument can't be resolved
                        // for some reason
                        let name = argument_name(id).expect("Argument has no name");
                        eprintln!("Unresolved argument {}", name);
                        LambdaItem::Call(Box::new(LambdaItem::Value(name)), Box::new(arg))
                    }
                    LambdaItem::Call(a, b) => {
                        // this call can't be reduced for some reason
                        LambdaItem::Call(Box::new(LambdaItem::Call(a, b)), Box::new(arg))
                    }
                    LambdaItem::Lambda(lambda) => lambda.reduce(args.clone(), Some(arg), index),
                }
            }
        }
    }
/// Args must have been reduced.
Args must have been reduced.
Args must have been reduced .
pub fn reduce(&self, args: &HashMap<u64, LambdaItem>, index: &LambdaIndex) -> LambdaItem {
        match self {
            &LambdaItem::Value(ref name) => LambdaItem::Value(name.clone()),
            &LambdaItem::Argument(id) => args.get(&id).unwrap_or(&LambdaItem::Argument(id)).clone(),
            &LambdaItem::Lambda(ref lambda) => LambdaItem::Lambda(Box::new(lambda.subst_args(args))),
            &LambdaItem::Call(ref callee, ref arg) => {
                let arg = arg.reduce(args, index);
                match callee.as_ref().reduce(args, index) {
                    LambdaItem::Value(ref name) => {
                        match index.get(name) {
                            Some(lambda) => lambda.reduce(args.clone(), Some(arg), index),
                            None => LambdaItem::Call(Box::new(LambdaItem::Value(name.clone())), Box::new(arg)),
                        }
                    }
                    LambdaItem::Argument(id) => {
                        // callee has been reduced above; this argument can't be resolved
                        // for some reason
                        let name = argument_name(id).expect("Argument has no name");
                        eprintln!("Unresolved argument {}", name);
                        LambdaItem::Call(Box::new(LambdaItem::Value(name)), Box::new(arg))
                    }
                    LambdaItem::Call(a, b) => {
                        // this call can't be reduced for some reason
                        LambdaItem::Call(Box::new(LambdaItem::Call(a, b)), Box::new(arg))
                    }
                    LambdaItem::Lambda(lambda) => lambda.reduce(args.clone(), Some(arg), index),
                }
            }
        }
    }
pub fn reduce ( & self , args : & HashMap < u64 , LambdaItem > , index : & LambdaIndex ) -> LambdaItem { match self { & LambdaItem :: Value ( ref name ) => LambdaItem :: Value ( name . clone ( ) ) , & LambdaItem :: Argument ( id ) => args . get ( & id ) . unwrap_or ( & LambdaItem :: Argument ( id ) ) . clone ( ) , & LambdaItem :: Lambda ( ref lambda ) => LambdaItem :: Lambda ( Box :: new ( lambda . subst_args ( args ) ) ) , & LambdaItem :: Call ( ref callee , ref arg ) => { let arg = arg . reduce ( args , index ) ; match callee . as_ref ( ) . reduce ( args , index ) { LambdaItem :: Value ( ref name ) => { match index . get ( name ) { Some ( lambda ) => lambda . reduce ( args . clone ( ) , Some ( arg ) , index ) , None => LambdaItem :: Call ( Box :: new ( LambdaItem :: Value ( name . clone ( ) ) ) , Box :: new ( arg ) ) , } } LambdaItem :: Argument ( id ) => { // callee has been reduced above; this argument can't be resolved // for some reason let name = argument_name ( id ) . expect ( " " ) ; eprintln ! ( " " name ) ; LambdaItem :: Call ( Box :: new ( LambdaItem :: Value ( name ) ) , Box :: new ( arg ) ) } LambdaItem :: Call ( a , b ) => { // this call can't be reduced for some reason LambdaItem :: Call ( Box :: new ( LambdaItem :: Call ( a , b ) ) , Box :: new ( arg ) ) } LambdaItem :: Lambda ( lambda ) => lambda . reduce ( args . clone ( ) , Some ( arg ) , index ) , } } } }
Args must have been reduced.
Args must have been reduced .
&self
args
&HashMap<u64, LambdaItem>
index
&LambdaIndex