pub fn pretty_print(&self) -> String {
        match *self {
            LispValue::Int(v) => v.to_string(),
            LispValue::Float(v) => v.to_string(),
            LispValue::Str(ref v) => format!("\"{}\"", v),
            LispValue::Symbol(ref v) => format!("{}", v),
            LispValue::Cons(ref car, ref cdr) => {
                let (s_car, s_cdr) = self.print_cons(&**car, &**cdr);
                format!("({} {})", s_car, s_cdr)
            },
            LispValue::Nil => "()".to_string(),
            LispValue::Bool(v) => if v {
                "#t".to_string()
            } else {
                "#f".to_string()
            },
            LispValue::Func(ref c) => format!("{}", c)
        }
    }
// Simple algorithm for pretty-printing an S-expression.
// The algorithm goes like this:
// 1) If self isn't a list, print it and return.
// 2) If self is a list, print an open paren.
//   2a) Print the car of the list.
//   2b) If cdr is a list, recurse to step 2a with cdr as the new list
//   2c) If cdr is nil, print nothing,
//   2d) If cdr is anything else, print a "." followed by a space
//       and recursively print the cdr.
// This function returns a string so "printing" isn't done, but it's basically
// the same thing.
Simple algorithm for pretty-printing an S-expression.
The algorithm goes like this:
1) If self isn't a list, print it and return.
2) If self is a list, print an open paren.
2a) Print the car of the list.
2b) If cdr is a list, recurse to step 2a with cdr as the new list
2c) If cdr is nil, print nothing,
2d) If cdr is anything else, print a "." followed by a space
and recursively print the cdr.
This function returns a string so "printing" isn't done, but it's basically
the same thing.
Simple algorithm for pretty - printing an S - expression . The algorithm goes like this : 1 ) If self isn ' t a list print it and return . 2 ) If self is a list print an open paren . 2a ) Print the car of the list . 2b ) If cdr is a list recurse to step 2a with cdr as the new list 2c ) If cdr is nil print nothing 2d ) If cdr is anything else print a " . " followed by a space and recursively print the cdr . This function returns a string so " printing " isn ' t done but it ' s basically the same thing .
pub fn pretty_print(&self) -> String {
        match *self {
            LispValue::Int(v) => v.to_string(),
            LispValue::Float(v) => v.to_string(),
            LispValue::Str(ref v) => format!("\"{}\"", v),
            LispValue::Symbol(ref v) => format!("{}", v),
            LispValue::Cons(ref car, ref cdr) => {
                let (s_car, s_cdr) = self.print_cons(&**car, &**cdr);
                format!("({} {})", s_car, s_cdr)
            },
            LispValue::Nil => "()".to_string(),
            LispValue::Bool(v) => if v {
                "#t".to_string()
            } else {
                "#f".to_string()
            },
            LispValue::Func(ref c) => format!("{}", c)
        }
    }
pub fn pretty_print ( & self ) -> String { match * self { LispValue :: Int ( v ) => v . to_string ( ) , LispValue :: Float ( v ) => v . to_string ( ) , LispValue :: Str ( ref v ) => format ! ( " \" \" " v ) , LispValue :: Symbol ( ref v ) => format ! ( " " v ) , LispValue :: Cons ( ref car , ref cdr ) => { let ( s_car , s_cdr ) = self . print_cons ( & * * car , & * * cdr ) ; format ! ( " " s_car s_cdr ) } , LispValue :: Nil => " " . to_string ( ) , LispValue :: Bool ( v ) => if v { " " . to_string ( ) } else { " " . to_string ( ) } , LispValue :: Func ( ref c ) => format ! ( " " c ) } }
Simple algorithm for pretty-printing an S-expression.
Simple algorithm for pretty - printing an S - expression .
&self
&self