CS 115 DrRacket Assignment 5
Beginning Student with List Abbreviations
Remember to use defined constants and helper functions where appropriate.
Copyright By PowCoder代写 加微信 powcoder
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