#lang racket ; Often it makes sense to only evaluate a term once and ; then use that value where needed (+ (* 3 4) (- (* 3 4) (/ 1 (* 3 4)))) ; replace each (* 3 4) by variable p which is pre-computed (define p (* 3 4)) (+ p (- p (/ 1 p))) ; wrap the expression in a closure that captures the p ; and apply it to the result of computing the term ( (lambda (p) (+ p (- p (/ 1 p))) ) (* 3 4) ) ; you can do this as much as you want ( (lambda (t1 t2 t3) (if (< t1 t2) (* t1 t3) (* t2 t3)) ) (+ 1 3) (- 4 6) 7 ) ; in unrestricted Scheme, use the let construction, which places ; the computation of the value beside the variable it is assigned to (let ( (p (* 3 4)) ) (+ p (- p (/ 1 p))) ) (let ( (t1 (+ 1 3)) (t2 (- 4 6)) (t3 7) ) (if (< t1 t2) (* t1 t3) (* t2 t3)) )