a04sol-cs135-w10

a04sol-cs135-w10 - ;; CELEB AEELGKHEK: fl EflLUiiflIE ;;...

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

View Full Document Right Arrow Icon
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
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ;; CELEB AEELGKHEK: fl EflLUiiflIE ;; BREE LUSHHEK ;; flueei_en E: iiEL.raL ;; eeuiL—pesiLiue : (iisLef inL} —s neL ;; Preduees Lne numee: ef eesitive eiemean in the given iisL. ;; lseieies: (eheek—espeet (eeunt—pesitive empty} U} (eheek—espeet (eeunt—pesitive (eens 1 empty}} 1} (eheek—espeet (eeunt—pesitive (eens —1 empty}} U} (define (eeunt—pesitive alen} (eene [(empty? alen} U] [(pesitive? (first alen}} (+ l (eeunt—pesitive (rest alen}}}] [else (eeunt—pesitive (rest alen}}]}} (eheek—espeet (eeunt—pesitive (eens l (eens —1 empty}}} 1} (eheek—espeet (eeunt—pesitive (eens 0 empty}} D} ;; seme—nege lye? : (iisLef inL} —} eeeieen ;; Enswers Lrue iii Lne give: iisL eenLe_ns aL iessL en; ;; lseieies: (eheek—espeet (seme—negative? empty} false} (eheek—espeet (seme—negative? (eens 1 empty}} fals } (eheek—espeet (seme—negative? (eens —1 empty}} true (define (seme—negative? alen} (:' 3) H//f (eene [(empty? alen} false] - , [(negative? (first alen}} true] [else (seme—negative? (rest alen} ]}} (eheek—espeet (seme—negative? (eens l (een —l mpty}}} true} (eheek—espeet (seme—negative? (gens empt } false} ;; flilflEEfle_ng? : (.Llfliiii .Ln1] —1+.bem;'eerff ;; enswers Lrue iff Lne given list al ernaLes eeLween even ane ass integers. ;; lseieies: (eheek—espeet (alternating? empty} true} (eheek—espeet (alternating? (eens 1 empty}} true} (eheek—espeet (alternating? (eens l (eens 2 empty}}} true} (eheek—espeet (alternating? (eens l (eens 3 empty}}} false} (define (alternating? alen} (eene [(empty? alen} true] [(empty? (rest alen}} true] [(and (even? (first alen}} (even? (first (rest alen}}}} false] [(and (edd? (first alen}} (eed? (first (rest alen}}}} false] [else (alternating? (rest alen}}]}} (eheek—espeet (alternating? (eens 2 empty}} true} (eheek—espeet (alternating? (eens 2 (eens 1 empty}}} true} (eheek—espeet (alternating? (eens 2 (eens 4 empty}}} false} ;; sr_LhmeL_e? : (lie ef inL} —} eeeieen This document is for the exclusive use of x284”. F r' £3. f1 (.3 "a" E I E- . - '_' -'- why-'1. I 'n. r. r ,- r _'?‘§:.:.-..a_a_'-’.—.n . true iff the given fist empty] true} emptyii trUEi (ccns 2 emptyiii true} (ccns 2 (ccna (ccna 4 emptyiiii ferme l l l l (check—expect (arithmetic? (check—expect (arithmetic? (ccne (check—expect (arithmetic? (ccne (check—expect (arithmetic? (ccne (check—expect (arithmetic? (ccne (define (arithmetic? alcn} (ccnd [(empty? alcn} true] [(empty? (rest alcnii true] [(empty? (rest (rest alcniii true] [ {= (— {— (firet (rest alcni} (first (rest (rest alcniii [else falae]ii (check—expect (check—expect (check—expect { (check—expect (arithmetic? { { Queet_en 3: |" F arithmetic? (ccna l (ccna l arithmetic? (ccna l arithmetic? (ccna 5 (define—struct lde (a E Ci} eeiue—ier—y Seiuee laempiee: (check—expect (check—expect the given LEE (wi iue int (sclve—fcr—y (sclve—fcr—y —} Jceiean ;: d (make—id (make—id a} U] (ccne (ccne (ccne (ccne (-3. f1 (ccns 2 (bl—'MM ’ 3 i l} U 3 i ar_LhmeLic (first alcni} eecuei'ice. 3 emptyiii} true] (ccna (ccna (ccna (ccna (define (sclve—fcr—y eqn n} (f (— (lde—C eqni (* (lde—a eqni a ] (ld — eqniii ;; L“_cu'.r-'—ma:“_y—seine iL'iE iii. int. —;'*- :(I‘ia'. 'infinity] ;; firtHMJcee tile rnrncerfafif sri;ctirnia " .-.- -I _.. """' _}£..-\.-.. 9-1 --.. r. r 'H_-'_E.. .1 r (check—expect (hcw—many—sclne (check—expect (hcw—many—sclne (make—lde 2 3 lflfli (make—lde 2 fl lDUli U 100} 5 8} __/ i (-3.13- DCJ. 611.9313. (first (rest alcniii} MI—‘U'IIJE- [l'lifl _ ef the given ide iie n 2} false} (arithmetic? (rest alcnii] emptyiiiii true} emptyiiii} false} emptyiiiii true} emptyiiii} true} > uaiue SE n. e ween few and high. Di (define (hcw—many—eclne eqn lcw high} (ccnd [(= (lde—a eqn} (lde—E eqni (lde—C eqni Di 'infinity] [(= (lde—a eqni (lde—E eqni D] D] [(and (= (lde—E eqn} D} (= (remainder (lde—C eqn] (lde—A eqnii U} ({= lcw (f (lde—C eqni (lde—a eqnii highi} 'infinity] [(= (lde—E eqni D} D] [(} lcw high] 0] [(integer? (acive—fcr—y eqn lcwi} (+ l (hcw—many—eclns eqn (addl lcw} highii] [else (hcw—many—sclne eqn (addl lcw} highi]ii (check—expect (hcw—many—eclne (make—lde U U D} D lDUi Tinfinity] (check—expect (hcw—many—eclne (make—lde U U l} D lDUi U} (check—expect (hcw—many—eclne (make—lde 2 U lUU} U 10} D} This document is for the exclusive use of x284”. {cheek—expect {hew—mshy—selhs {make—lee 2 U lUU] 5U 50] 'ihfihity] {eheek—espeet {hew—mshy—selhs {make—lee 2 3 10D] 8 5] fl] {eheek—espeet {hew—mshy—selhs {make—lee 2 3 lUU] 5 5] 1] {eheek—espeet {hew—mshy—selhs {make—lee 2 3 lUU} E E] D] ;; seiis ide int ihL —} {siiei {iistef Ease] 'ifliihity] ;; Preduees Lhe iisL ef seistieis SI the given iee thL iie he wee“ iew she high. ;; lsempies: {eheek—espeet {selhs imske—lde 2 3 100} 5 8] {eens {make—pesh 5 30] {eehs imske—pesn 8 28} emptyiii {eheek—espeet {selhs {mske—lde 2 fl lflfll} U lUD] empty] {define {selhs eqh lew high] {send [i= {lee—s eqh] {lee—E eqh] {lde—C eqn] 0] 'ihfihity] [i= {lee—s eqh] ilde—E eqh] D] empty] [{shd {= {lee—B eqh} U} {= {remainder {lee—C eqn] {lee—A eqnii D} (e: lew if {lee—C eqh] {lee—h eqhii highii 'infihity] [i= {lee—E eqn] 0] empty] [is low high] empty] [iihteger? {selye—fer—y eqn lewii {sens {make—pesh lew {selye—fer—y eqh lewii is {selhs eqh {sddl lew] highii] [else {selhs eqh {sddl lew] high]]]i {eheek—espeet {selhs {make—lee U U D] D lDU] Tiflfiflixa}\\h {eheek—espeet {selhs {make—lee U U l] D 100] empty] {eheek—espeet {selhs {make—lee 2 U lflU} U 10} ty] 2;* {eheek—espeet {selhs {make—lee 2 U lDD] ED 5 _T§hfihipg{f {eheek—espeet {selhs {make—lee 2 3 lUD] B Eiggmpt ]_ {cheek—expect {selhs {make—lee 2 ” 100] {e ns {m e—pesh 5 30] emptyii i 2 BEKUE Questieh peiy.:s1 h j 5] {eheek—espeet selhs {make—lee 3 lflij’fi E em y ;, eyei—peiy iiisLei 34m] Hum —} Elm ;; Preduees the UfiihE eh siflee by sue Li hL_ig the given UfiiME st K _:Le Lhe ;, qiyeh peiyhemiei ;; lsempies: {eheek—espeet {eysl—pely {eehs U empty] 10] U] {eheek—espeet {eysl—pely {sens U {eehs 1 empty]] 10] 10] {eheek—espeet {eysl—pely {sens U {eehs D {sons 1 empty]]] 10} 100] {define {eysl—pely pely s} {send [{empty? {rest pelyii {first pelyi] [else {+ {first pely] {* s {eysl—pely {rest pely] s]]i]}i This document is for the exclusive use of x284”. ...
View Full Document

This note was uploaded on 10/02/2011 for the course CS 135 taught by Professor Vasiga during the Winter '07 term at Waterloo.

Page1 / 3

a04sol-cs135-w10 - ;; CELEB AEELGKHEK: fl EflLUiiflIE ;;...

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

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