;; The first three lines of this file were inserted by DrRacket. They record metadata ;; about the language level of this file in a form that our tools can easily process. #reader(lib "htdp-beginner-reader.ss" "lang")((modname pizza) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f () #f))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; A hello-world program: "Hello World" ; Racket is an industrial-strength scheme ; Scheme is an elegant, minimal version of Lisp ; Lisp is the 2nd-oldest high-level language still in use (after Fortran) ; (Lisp ~ 1965) ; When calling 'substring', we pass it 3 inputs (string, natural-number, natural-number), ; and we get a string back. ; In Ada, python: substring("Mississippi", 2, 5) ; When calling '+', we pass it 2 [or more] inputs (number, number) ; and we get a number back ;; In Ada, python: 2 + 3 ;; "operators" are just functions that are called with a different syntax. ; IN racket: "(" means 'call a function'. ; Syntax: ( ... ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; pizza-area : non-negative real -> non-negative real ; The area (in sq.in.) of a pizza, whose diameter is `diam` (in inches) ; (define (pizza-area diam) (* pi (sqr (/ diam 2)))) (check-expect (pizza-area 0) 0) (check-within (pizza-area 2) pi 0.0000001) (check-within (pizza-area 20) (* 100 pi) 0.0000001) (check-within (pizza-area 2.5) 4.91 0.03)