a5q2 - void) ; ;; Effects: ;; Changes one to original value...

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

View Full Document Right Arrow Icon
;; 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-advanced-reader.ss" "lang")((modname a5q2) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #t #t none #f ()))) ;;Assignment 5 Question 2 ;; Ru Wang r46wang 20319247 ;; a5q2 ;; State variables: ;; one: any ;; holds the first value, initially (define one 2) ;; two: any ;; holds the second value, initially (define two 3) ;; three: any ;; holds the third value, initially (define three 1) ;; shift: (void) -> (void) ; ;; this function neither consumes or produces anything. (consumes void and produces
Background image of page 1

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

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

Unformatted text preview: void) ; ;; Effects: ;; Changes one to original value of three ;; Change two to original value of one ;; Change three to original value of two ; ;; Example: after the function has been called, one will contain the initial value of three, two will contain the initial value of one, and three will contain the initial value of two. ; (define (shift) (local [(define x one)] (begin (set! one three) (set! three two) (set! two x)))) ;; Tests: (check-expect (begin (set! one 'a) (set! three 'b) (shift) (equal? one 'b)) true) (check-expect (begin (set! two 'a) (set! one 'b) (shift) (equal? two 'b)) true) (check-expect (begin (set! three 'a) (set! two 'b) (shift) (equal? three 'b)) true)...
View Full Document

Page1 / 2

a5q2 - void) ; ;; Effects: ;; Changes one to original value...

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