pub fn core_len(&mut self, chunk: &Chunk, i: usize) -> i32 {
        if self.stack.len() < 1 {
            print_error(chunk, i, "len requires one argument");
            return 0;
        }

        let lst_rr = self.stack.pop().unwrap();
        let lst_rrb = lst_rr.borrow();
        match &*lst_rrb {
            Value::List(lst) => {
                let len = lst.len();
                self.stack
                    .push(Rc::new(RefCell::new(Value::Int(len as i32))));
            }
            Value::String(s, _) => {
                let len = s.len();
                self.stack
                    .push(Rc::new(RefCell::new(Value::Int(len as i32))));
            }
            _ => {
                print_error(chunk, i, "len argument must be a list or a string");
                return 0;
            }
        }
        return 1;
    }
/// If the topmost element is a list, adds the length of that list
/// onto the stack.  If the topmost element is a string, adds the
/// length of that sting onto the stack.
If the topmost element is a list, adds the length of that list
onto the stack.  If the topmost element is a string, adds the
length of that sting onto the stack.
If the topmost element is a list adds the length of that list onto the stack . If the topmost element is a string adds the length of that sting onto the stack .
pub fn core_len(&mut self, chunk: &Chunk, i: usize) -> i32 {
        if self.stack.len() < 1 {
            print_error(chunk, i, "len requires one argument");
            return 0;
        }
        let lst_rr = self.stack.pop().unwrap();
        let lst_rrb = lst_rr.borrow();
        match &*lst_rrb {
            Value::List(lst) => {
                let len = lst.len();
                self.stack
                    .push(Rc::new(RefCell::new(Value::Int(len as i32))));
            }
            Value::String(s, _) => {
                let len = s.len();
                self.stack
                    .push(Rc::new(RefCell::new(Value::Int(len as i32))));
            }
            _ => {
                print_error(chunk, i, "len argument must be a list or a string");
                return 0;
            }
        }
        return 1;
    }
pub fn core_len ( & mut self , chunk : & Chunk , i : usize ) -> i32 { if self . stack . len ( ) < 1 { print_error ( chunk , i , " " ) ; return 0 ; } let lst_rr = self . stack . pop ( ) . unwrap ( ) ; let lst_rrb = lst_rr . borrow ( ) ; match & * lst_rrb { Value :: List ( lst ) => { let len = lst . len ( ) ; self . stack . push ( Rc :: new ( RefCell :: new ( Value :: Int ( len as i32 ) ) ) ) ; } Value :: String ( s , _ ) => { let len = s . len ( ) ; self . stack . push ( Rc :: new ( RefCell :: new ( Value :: Int ( len as i32 ) ) ) ) ; } _ => { print_error ( chunk , i , " " ) ; return 0 ; } } return 1 ; }
If the topmost element is a list, adds the length of that list
onto the stack.
If the topmost element is a list adds the length of that list onto the stack .
&mut self
chunk
&Chunk
i
usize