pub fn core_nth(&mut self, chunk: &Chunk, i: usize) -> i32 {
        if self.stack.len() < 2 {
            print_error(chunk, i, "nth requires two arguments");
            return 0;
        }

        let index_rr = self.stack.pop().unwrap();
        let index_rrb = index_rr.borrow();
        let index_int_opt = index_rrb.to_int();

        let lst_rr = self.stack.pop().unwrap();
        let lst_rrb = lst_rr.borrow();

        match (index_int_opt, &*lst_rrb) {
            (Some(index), Value::List(lst)) => {
                let element = lst[index as usize].clone();
                self.stack.push(element);
            }
            (Some(_), _) => {
                print_error(chunk, i, "first nth argument must be list");
                return 0;
            }
            (_, _) => {
                print_error(chunk, i, "second nth argument must be integer");
                return 0;
            }
        }
        return 1;
    }
/// Takes a list and an index as its arguments.  Gets the element
/// at the given index from the list and places it onto the stack.
Takes a list and an index as its arguments.  Gets the element
at the given index from the list and places it onto the stack.
Takes a list and an index as its arguments . Gets the element at the given index from the list and places it onto the stack .
pub fn core_nth(&mut self, chunk: &Chunk, i: usize) -> i32 {
        if self.stack.len() < 2 {
            print_error(chunk, i, "nth requires two arguments");
            return 0;
        }
        let index_rr = self.stack.pop().unwrap();
        let index_rrb = index_rr.borrow();
        let index_int_opt = index_rrb.to_int();
        let lst_rr = self.stack.pop().unwrap();
        let lst_rrb = lst_rr.borrow();
        match (index_int_opt, &*lst_rrb) {
            (Some(index), Value::List(lst)) => {
                let element = lst[index as usize].clone();
                self.stack.push(element);
            }
            (Some(_), _) => {
                print_error(chunk, i, "first nth argument must be list");
                return 0;
            }
            (_, _) => {
                print_error(chunk, i, "second nth argument must be integer");
                return 0;
            }
        }
        return 1;
    }
pub fn core_nth ( & mut self , chunk : & Chunk , i : usize ) -> i32 { if self . stack . len ( ) < 2 { print_error ( chunk , i , " " ) ; return 0 ; } let index_rr = self . stack . pop ( ) . unwrap ( ) ; let index_rrb = index_rr . borrow ( ) ; let index_int_opt = index_rrb . to_int ( ) ; let lst_rr = self . stack . pop ( ) . unwrap ( ) ; let lst_rrb = lst_rr . borrow ( ) ; match ( index_int_opt , & * lst_rrb ) { ( Some ( index ) , Value :: List ( lst ) ) => { let element = lst [ index as usize ] . clone ( ) ; self . stack . push ( element ) ; } ( Some ( _ ) , _ ) => { print_error ( chunk , i , " " ) ; return 0 ; } ( _ , _ ) => { print_error ( chunk , i , " " ) ; return 0 ; } } return 1 ; }
Takes a list and an index as its arguments.
Takes a list and an index as its arguments .
&mut self
chunk
&Chunk
i
usize