;; The first three lines of this file were inserted by DrScheme. They record metadata ;; about the language level of this file in a form that our tools can easily process. #reader(lib "htdp-intermediate-reader.ss" "lang")((modname 18.1.1) (read-case-sensitive #t) (teachpacks ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "dir.ss" "teachpack" "htdp") (lib "hangman.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "dir.ss" "teachpack" "htdp") (lib "hangman.ss" "teachpack" "htdp"))))) (local ( (define x (* y 3)) ) (* x x)) (local ( (define (odd an) (cond [(zero? an) false] [else (even (sub1 an))])) (define (even an) (cond [(zero? an) true] [else (odd (sub1 an))]))) (even a-nat-num)) (local ( (define (f x) (g x (+ x 1))) (define (g x y) (f (+ x y))) ) (+ (f 10) (g 10 20)) ) (local ( (define x 10) (y (+ x x))) y) (local ( (define (f x) (+ (* x x) (* 3 x) 15)) (define x 100) (define f@100 (f x)) ) f@100 x) (local ( (define (f x) (+ (* x x) (* 3 x) 14)) (define x 100) (define f (f x))) f) 1. (define A-CONSTANT (not (local ( (define (odd an) (cond [(= an 0) false] [else (even (- an 1))])) (define (even an) (cond [(= an 0) true] [else (odd (- an 1))])) ) (even a-nat-num) ) )) 2. (+ (local ( (define (f x) (+ (* x x) (* 3 x) 15)) (define x 100) (define f@100 (f x)) ) f@100) 1000) 3. (local ( (define CONST 100) (define f x (+ x CONST)) ) (define (g x y z) (f (+ x (* y z)))) ) = (define (D x y) (local ((define x2 (* x x)) (define y2 (* y y))) (sqrt (+ x2 y2)))) (+ (local ((define x2 (* 0 0)) (define y2 (* 1 1))) (sqrt (+ x2 y2))) (D 3 4)) ;; sort : list-of-numbers -> list-of-numbers (define (sort alon) (local ( (define (sort alon) (cond [(empty? alon) empty] [(cons? alon) (insert (first alon) (sort (rest alon)))])) (define (insert an alon) (cond [(empty? alon) (list an)] [else (cond [(> an (first alon)) (cons an alon)] [else (cons (first alon) (insert an (rest alon)))])])) ) (sort alon)))