#lang racket (define (minimum L) (let ((x (car L)) (xs (cdr L))) (if (null? xs) x (minimum (cons (if (< x (car xs)) x (car xs)) (cdr xs)))))) (minimum '(2 2 1 4 5)) (define (minimum2 x . rest) (if (null? rest) x (apply minimum2 (cons (if (< x (car rest)) x (car rest)) (cdr rest))))) (minimum2 5 9 7 88 54 79) (let ((x 0)) (let label () (when (< x 10) (display x) (newline) (set! x (+ x 1)) (label)))) (let label ((x 10)) (when (> x 0) (display x) (newline) (label (- x 1)))) (define (fact x) (define (fact-tail x accum) (if (= x 0) accum (fact-tail (- x 1) (* accum x)))) (fact-tail x 1)) (fact 10) (for-each (lambda (x) (display x) (newline)) '(this is it)) (define (vector-for-each body vect) (let ((max (- (vector-length vect) 1))) (let loop ((i 0)) (body (vector-ref vect i)) (when (< i max) (loop (+ i 1)))))) (vector-for-each (lambda (x) (display x) (newline)) #(this is it)) (eq? 'casa 'casa) (eq? "casa" "casa") (eqv? 2 2) (make-vector 5 'a) (equal? (make-vector 5 'a) (make-vector 5 'a)) (equal? (make-vector 5 'a) (make-vector 5 'b)) (eqv? (make-vector 5 'a) (make-vector 5 'a)) (case (car(cdr '(c a))) ((a e i o u) 'vowel) ((w y) 'semivowel) (else 'consonant)) (cond ((> 3 2) 'greater) ((< 1 3) 'less) (else 'equal)) (define (f) (vector 1 2 3)) (define v (f)) (vector-set! v 0 20) (display v) (struct being ( name (age #:mutable) )) (define (being-show x) (newline) (display (being-name x)) (newline) (display (being-age x))) (define james (being "James" 30)) (being-show james) (set-being-age! james 40) (being-show james) (define (say-hello x) (if (being? x) (begin (being-show x) (newline) (display "regards") ) (error "not a being" x))) (say-hello james) (struct may-being being ((alive? #:mutable))) (define john (may-being "John" 87 #t)) (say-hello john)