CS 115 DrRacket Assignment 5
Beginning Student with List Abbreviations
Remember to use defined constants and helper functions where appropriate.
Copyright By PowCoder代写加微信 assignmentchef
Follow the full design recipe and the Coding Style document up to and including Section 3.6.2.
define , and , or , not , cond , else , check-expect , check-within , equal? Any type predicate such as number? or boolean?
Any functions on numbers found in Section 2.6 of the Racket documentation
Any functions on characters found in Section 2.11 of the Racket documentation
Any functions on strings found in Section 2.12 of the Racket documentation
The function symbol=?
The list functions and values cons , first , second , third , rest , empty , empty? , and list You must not use boolean=?
All test data for correctness will always meet the stated assumptions for consumed values.
1 ;; A PFD, or prime factor decomposition, is a (listof Nat) 2 ;; Requires: the elements are in ascending order
3 ;; the elements are prime numbers.
!”#$%&'()*+,(&-)-(&’.”+)+/”(+”(0/%1(.$’2
M5+7/6F$-L$+7-0*5D$/GH-5/57+J$2/$2*88$W?+7$8*+7$7E/$H0*4/$L6,7-0+J$2*7E$0/H/7*7*-5B$&-$24 = 23 ⋅ 3 = 2 ⋅ 2 ⋅ 2 ⋅ 3$2*88$T/$0/H0/+/57/F$6+$(list 2 2 2 3)J$65F$42 = 2 ⋅ 3 ⋅ 7$2*88$T/ 0/H0/+/57/F$6+$(list 2 3 7)B$3E/$5?4T/0$’$*+$7E/$0/+?87$-L$7E/$X4H7Q$P0-F?,7J$+-$*7+$H0*4/$L6,7-0$F/,-4H-+*7*-5$*+$emptyB$C$H0*4/$5?4T/0$E6+$-58Q$-5/$H0*4/$L6,7-0J$+-$7E/$PV)$-L$6 H0*4/$2*88$T/$6$8*+7$7E67$,-576*5+$7E67$.68?/$-58QB
“0*7/$6$L?5,7*-5$pfdB$M7$,-5+?4/+$6$H-+*7*./$*57/D/0$nJ$65F$H0-F?,/+$7E/$PFD$7E67$0/H0/+/57+$nB$V-0$/G64H8/J
> (pfd 12)
(list 2 2 3)
> (pfd 8191) ; a Mersenne prime:
(list 8191)
Y-?$,65$D/5/067/$7E/$+-8?7*-5$8*+7$*5$7E/$,-00/,7$-0F/0$?+*5D$65$6HH0-H0*67/$0/,?0+*-5$-5$567?068$5?4T/0+B$M7$+E-?8F$5-7$T/$5/,/++60Q$7-$+-07B
/#.*0&1$(2#.%&,+#.2&!”#$%&'()*+”&,%)+$!+-#*#+.&34&5(.,6&*5%.&7-%&*5#-&*+&#.’+”$&4+7″&)+,%&,%-#2.8$M$4*DE7$,68,?867/$7E/$PV)$-L$6$5?4T/0$TQ$F062*5D$6$70//B$C7$/6,E$5-F/J$M$Z5F$7E/$+4688/+7$H0*4/ L6,7-0$-L$7E/$5?4T/0$M[4$,-5+*F/0*5DJ$65F$F*.*F/$*7$-?7#
&-$*7$4?+7$T/$7E67$(pfd 24) ⇒ (cons 2 (cons 2 (cons 2 (cons 3 empty)))) ⇒ (list 2 2 2 3)J$6+$F/+*0/FB
&-$*7$4?+7$T/$7E67$(pfd 42) ⇒ (cons 2 (cons 3 (cons 7 empty))) ⇒ (list 2 3 7)J$6+$F/+*0/FB
C$L/2$7E*5D+$7-$,-5+*F/0#
1. The base case is strange; what is it?
2. We are not just counting up or down; how are we approaching the base case?
3. Somehow hidden we need to count up to track which prime divisor we are considering.
&?T4*7$Q-?0$+-8?7*-5$*5$7E/$Z8/$a05q1.rktB 7′.2#)%”*=8*/($;>>6.*/%$#)”3
&-4/7*4/+$2E/5$+-07*5DJ$2/$2657$7-$+-07$?+*5D$6$H0-H/07Q$-L$/6,E$.68?/J$*5+7/6F$-L$7E/$.68?/$*7+/8LB$3E/5$2/$E6./$7-$,-5+*F/0$2E67$7-$F-$L-0$.68?/+$L-0$2E*,E$7E/$H0-H/07Q$*+$/U?68B
V-0$/G64H8/J$2/$,-?8F$+-07$6$8*+7$-L$+70*5D+$*5$6+,/5F*5D$-0F/0$TQ$8/5D7EB$3E/5$(list “able” “was” “I” “ere” “I” “saw” “Elba”)$,-?8F$T/,-4/$(list “I” “I” “saw” “ere” “was” “Elba” “able”)J$T?7$*7$,-?8F$W?+7$6+$2/88$T/,-4/$(list “I” “I” “was” “ere” “saw” “able” “Elba”)J$-0$+/./068$-7E/0$-H7*-5+B$3E/+/$8*+7+$60/$*5$*5,0/6+*5D$-0F/0$TQ$8/5D7EB “E*,E$+E-?8F$2/$H0/L/0
M7$7?05+$-?7$7E67$-5/$6HH0-6,E$7E67$*+$-L7/5$?+/L?8$*+$7-$46K/$7E/$+-07*5D$-*(39%B$C$4/7E-F$-L$+-07*5D$*+$-*(39%$*L$6L7/0$+-07*5DJ$7E/$-0F/0$-L$*7/4+$7E67$60/$]7E/$+64/]$6,,-0F*5D$7-$7E/$+-07*5D ,0*7/0*-5$*+$?5,E65D/FB
V-0$/G64H8/J$(list “I” “I” “was” “ere” “saw” “able” “Elba”)$*+$7E/$0/+?87$-L$+-07*5D$(list “able” “was” “I” “ere” “I” “saw” “Elba”)$TQ$+70*5D$8/5D7EJ$?+*5D$6$+76T8/ +-07B$A5$7E/$-7E/0$E65FJ$(list “I” “I” “saw” “ere” “was” “Elba” “able”)$E6+$5-7$T//5$+-07/F$*5$6$+76T8/$4655/0J$+*5,/$”saw”$65F$”was”$E6./$7E/$+64/$8/5D7EJ$T?7$”saw” H0/.*-?+8Q$,64/$6L7/0$”was”J$65F$5-2$,-4/+$T/L-0/B
M5$C++*D54/57$
(list “IT” “ONE” “OF” “DEAN” “CAN” “JEST”)
&-07*5D$H?7+$7E/4$*5$-0F/0$TQ$+,-0/B$a?7$+*5,/$M3$,64/$T/L-0/$A1XJ$65F$7E/Q$E6./$/U?68$+,-0/+J$M3$+7*88$,-4/+$T/L-0/$A1XB$&*4*8608QJ$AV$65F$)XC1$E6./$/U?68$+,-0/+J$65F$0/46*5$*5$7E/$+64/ -0F/0B
3E*5K$6T-?7$4-F/88*5D$Q-?0$+-8?7*-5$?H-5$7E/$*5+/07*-5$+-07$68D-0*7E4$+E-25$*5$S/++-5$9bB<J$65F$20*7*5D$Q-?0$-25$E/8H/0$L?5,7*-5$7-$,-4H60/$72-$2-0F+B$ML$6$2-0F$6HH/60+$4?87*H8/$7*4/+$*5 7E/$*5H?7$8*+7J$*7$+E-?8F$6HH/60$7E/$+64/$5?4T/0$-L$7*4/+$*5$7E/$0/+?87BY-?$46Q$?+/$Q-?0$-25$+-8?7*-5$7-$7E/$&,06TT8/$+,-0*5D$H0-T8/4$L0-4$C++*D54/57$<B$ML$Q-?$H0/L/0J$Q-?$46Q$?+/$7E/$H-+7/F$+-8?7*-5J$-5,/$*7$*+$6.6*86T8/B &?T4*7$Q-?0$+-8?7*-5$*5$7E/$Z8/$a05q2.rktB$ “/$60/$D-*5D$7-$7E*5K$6T-?7$8*+7+$-L$8/5D7E$/G6,78Q$=J$0/H0/+/57*5D$65$6?7E-0J$7*78/J$65F$5?4T/0$-L$H6D/+B$X6,E$+?,E$8*+7$2/$2*88$,688$6$BookB$a/,6?+/$Book$*+$6$,-4H-?5FJ$2/c88$*5,8?F/$6 ,-5+70?,7-0$65F$65F$+/8/,7-0+$L-0$*7# ;; a Book is a (list Nat) ;; Constructor (define (make-book author title pages) (list author title pages)) ;; Selectors (define (book-author b) (first b)) (define (book-title b) (second b)) (define (book-pages b) (third b)) ;; A BookSet (BS) is a (listof Book)O/0/$60/$6$L/2$/G64H8/+$-L$6$Book#1 (define weir (make-book “Weir” “The Martian” 369))2 (define euclid (make-book “Euclid” “Elements” 654)) “/$,65$7E/5$46K/$6$BSJ$2E*,E$,65$+7-0/$6$8-7$-L$*5L-0467*-5B$V-0$/G64H8/# (define booklist(make-book “Liu” “The Three Body Problem” 302)(make-book “Nawaz” “Songs for the End of the World” 400)(make-book “Heinlein” “The Moon Is a” 382)(make-book “Weir” “The Martian” 369)(make-book “Clancy” “The Sum of All Fears” 798)(make-book “Nawaz” “Bone and Bread” 445)(make-book “Heinlein” “Stranger in a Strange Land” 408)(make-book “Heinlein” “Starship Troopers” 263)))”0*7/$6$L?5,7*-5$(total-pages books author)J$2E/0/$books$*+$6$BSJ$65F$author$*+$/*7E/0$6$Str$-0$’anyB$”E/5$author$*+$6$StrJ$7E/$L?5,7*-5$H0-F?,/+$7E/$7-768$5?4T/0$-L$H6D/+$*5 books$20*77/5$TQ$7E67$6?7E-0B$”E/5$author$*+$’anyJ$7E/$L?5,7*-5$H0-F?,/+$7E/$7-768$5?4T/0$-L$H6D/+$*5$books$20*77/5$TQ$65Q$6?7E-0B$V-0$/G64H8/#1 (check-expect (total-pages booklist “Nawaz”) 845) 2 (check-expect (total-pages booklist “Seuss”) 0)3 (check-expect (total-pages booklist ‘any) 3367)%-HQ$7E/$F676$F/Z5*7*-5+$65F$,-5./5*/5,/$L?5,7*-5+$6T-./$*57-$Q-?0$+-8?7*-5J$65F$?+/$7E/4B$Y-?$F-$5-7$5//F$7-$H0-.*F/$F/+*D5$0/,*H/+$L-0$7E/$H0-.*F/F$,-5+70?,7-0$-0$+/8/,7-0+B &?T4*7$Q-?0$+-8?7*-5$*5$7E/$Z8/$a05q3.rktB程序代写 CS代考 加微信: assignmentchef QQ: 1823890830 Email: [email protected]
Reviews
There are no reviews yet.