sicp-ex-4.1



<< Previous exercise (3.82) | Index | Next exercise (4.2) >>


meteorgan

  
  
 ;; left to righ 
 (define (list-of-values1 exps env) 
   (if (no-operand? exps) 
       '() 
       (let* ((left (eval (first-operand exps) env)) 
                 (right (eval (rest-operands exps) env))) 
         (cons left right)))) 
  
 ;; right to left 
 (define (list-of-values2 exps env) 
   (if (no-operand? exps) 
       '() 
       (let* ((left (eval (rest-operands exps) env)) 
                 (right (eval (first-operand exps) env))) 
         (cons left right)))) 
 (define (list-of-values-lr exps env) 
   (if (no-operands? exps) 
       '() 
       (let ((first (eval (first-operand exps) env))) 
         (let ((rest (list-of-values-lr (rest-operands exps) env))) 
           (cons first rest))))) 
  
 (define (list-of-values-rl exps env) 
   (if (no-operands? exps) 
       '() 
       (let ((rest (list-of-values-rl (rest-operands exps) env))) 
         (let ((first (eval (first-operand exps) env))) 
           (cons first rest)))))