;; ------------------------------------------------------------------------- ;; a Racket version of the "block structure" example in Java ;; ------------------------------------------------------------------------- #lang racket ;; ------------------------------------------------------------------------ ;; a helper function a la println() in Java (only better) ;; NOTE: display, newline, and set! are non-functional features of Racket. ;; I use them here only to mimic the Java example. ;; They are off-limits in our solutions for now <------------- ;; because you do not need them for any problem. <------------- ;; ------------------------------------------------------------------------- (define println (lambda args (map display args) (newline))) ;; ------------------------------------------------------------------------ (let ((x 4) ;; Block 1 (y 0)) (let* ((x 3) ;; Block 2 (z (+ x 1))) (println x " " z)) (set! y (+ x 1)) (println x " " y)) ;; ------------------------------------------------------------------------