On this page:
2.11.1 Objectives
2.11.2 Exercises (due 2011/  10/  21 08:  45:  00)
2.11.3 Optional Exercises (due 2011/  10/  26 08:  45:  00)
2.11.4 Notes

2.11 Producing Lists; Sorting

A map, a filter,

A weird morphism

Lists are wicked cool

2.11.1 Objectives

At the end of this class, you should know:

    At the end of this class, you should be able:

    2.11.2 Exercises (due 2011/10/21 08:45:00)

    1. Write a function called convertFCs that takes a list of Fahrenheit temperatures and produces a list of Celsius temperatures.

    2. Write a function eliminateExpensive that takes a list of toy prices and returns a list with all the elements of the given list, except those that cost more than $10.

    3. Write the function nameRobot that takes a list of toy descriptions (strings) and returns a more specific list where robot has been replaced with wally.

    4. Generalize nameRobot to substitute that takes a list of toy descriptions, a target, and new. It replaces all occurrences of the target with the new.

    5. Write a function called insert that takes a number and a sorted list of numbers and returns a new sort list of number where the new number is added in the correct spot. [Sorted meaning the numbers go from smallest to largest.]

    6. Write a function called sort that takes an unsorted list of numbers and returns a sorted list of numbers. [Hint: Use insert!]

    2.11.3 Optional Exercises (due 2011/10/26 08:45:00)

    7. Write a function called replaceNegatives that takes a list of numbers and a positive number and produces a list identical to the given list except that all negative numbers in the list have been replaced by the positive number.

    8. Write the function recall that takes a list of toy descriptions and a target and produces a list that does not contain the target but contains everything else in the input list.

    9. Write the function taxinate that takes a list of toy prices and returns a list where each item costs 10% more.

    2.11.4 Notes

    These notes are primarily for my sake, but I don’t see any reason to hide them from you.

    Use wage ($12/h)

     

    Make hoursToWages

     

    Write eliminateOverworkers (more than 100 hours)

     

    Write cap (doesn't remove over 100, but makes them 100)

     

    Generalize cap to take an argument specifying how much overworking is.

     

    Write update (replace at at least a position)