
(define reduce
  (lambda (op base l)
    (if (null? l) 
        (begin (browse-environment) base)
        (op (car l) (reduce op base (cdr l))))))

(reduce + 0 '(2 3 4))

(define factit
  (lambda (n)
    (letrec
        ((fit
          (lambda (n acc)
            (if (= n 0) 
                (begin
                  (browse-environment) acc)
                (fit (- n 1) (* n acc))))))
      (fit n 1))))

(factit 6)

(define rec
  (lambda (n stop)
    (display n) (newline)
    (if (= n 0) 
        (begin
          (browse-environment)
          (stop 0))
        (begin
          (rec (- n 1) stop)
          (display n) (newline)))))

(rec 6 (lambda (x) '()))
