10.01 web-prog-intro

10.01 web-prog-intro - ; The define-script macro ; (define...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
;;;; The define-script macro ;;;; (define abort #f) (let/cc grab-abort (set! abort grab-abort)) (define-syntax define-script (syntax-rules () [(define-script (script-name arg . ..) body) (define (script-name arg . ..) (abort body))])) ;;;;; the original voter program ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; request-age-page : -> void ;; prompts user to input their age (define (request-age-page) (printf "Enter your age: ")) ;; age-page-nonweb : -> void ;; displays ability to vote based on user's age (define (age-page-nonweb) (begin (request-age-page) (local ((define age (read))) (cond [(>= age 18) (printf "Don't forget to vote!")] [else (printf "You'll be able to vote in ~a years" (- 18 age))])))) ;;;; the broken script-based voter program ;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; request-age-page-script : -> void ;; prompts user to input their age (define-script (request-age-page-script) (printf "Enter your age: ")) ;; age-page : -> void ;; displays ability to vote based on user's age (define-script (age-page)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

10.01 web-prog-intro - ; The define-script macro ; (define...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online