Chapter 3 Daily 06
Write the type signature and function for each problem.
-
Add a 3 to the front of a list of numbers.
-
Add a 4 to the back of a list of numbers.
-
Add a 5 in the middle of a list of numbers. If possible, insert the 5 so there are exactly the same number of numbers before and after it, otherwise put the extra number after it.
-
Switch the front and back number in a list of numbers. Leave the others the same.
-
Delete the middle number of a list of numbers. Assume the length is odd.
-
delRange start end numList
: Remove items from indexstart
through indexend
from the numbers list.delRange 1 4 [10,11,12,13,14,15] == [10,15] delRange 3 7 "PlatypusFiesta" == "PlaFiesta" Work: PlatypusFiesta 01234567Fiesta
-
(
moveOdd
) Move any odd numbers from the start of a list to the end. Stop moving when you find an even number. If there are no even numbers, the list does not change.moveOdd [1,3,4,5,6] == [4,5,6,1,3] moveOdd [2,3,5,7,9] == [2,3,5,7,9]
-
(
vDub
) Double all of the vowels in a word.vDub "Alligator" == "AAlliigaatoor"
Note
Using if
statements for 7 and 8 is fine. Your code might feel more
like “Racket code” for those… until we learn about
guards.