CMSC 308 Fall 2015
 09/24/2015 Functional Programming Due:  Thursday, October 1 12:30pm

### Assignment:    (15 points)

For this assignment you will be asked to write some Racket functions.

1)  Write a function len, which takes a list as a parameter, and returns the length of that list.
eg:
 Expression Result (len ‘(a b c)) 3 (len ‘() ) 0 (len (list (+ 1 7) 4 5) ) 3

You may NOT utilize the builtin function "length" in your solution.

2)  Write a function LongerThan, which takes two lists as parameters and determines if the first parameter is longer than the second.
eg:
 (LongerThan ‘(a b c)  ‘(a b) ) TRUE  the first list is longer than the second (LongerThan ‘(x)  (list (+ 1 7) 4)) FALSE  the list (x) is shorter than the list (8 4) (LongerThan ‘(a b c)  ‘(c d e) ) FALSE (different lengths)

a)  Do this utilizing the len function you wrote for number 1.

b)  Do this WITHOUT utilizing the len function above or the builtin length function.

3)  Consider lists of people's pizza preferences.   More specifically: each item in the list is a list of two items.  The first is a person's name.  The second is a list of topping that person likes on their pizza.   For instance:

'((Robert (pepperoni))
(Joan   (mushrooms sausage))
(Jane   (pepperoni sausage olives))
(Joe    (onions peppers))
(Tamara (ham pineapple))
(Anne   ())
(Scott  (mushrooms pepperoni olives))
(Chris  (pepperoni))
(Lana   (artichokes peppers))
)

This above example will be used to describe the functions below.

(define PizzaParty
'((Robert (pepperoni))
(Joan   (mushrooms sausage))
(Jane   (pepperoni sausage olives))
(Joe    (onions peppers))
(Tamara (ham pineapple))
(Anne   ())
(Scott  (mushrooms pepperoni olives))
(Chris  (pepperoni))
(Lana   (artichokes peppers))
)
)

a)   Write a function names which returns a list of the names of all of the people in the list, which is a parameter.
Example:
(names PizzaParty)      should produce
(Robert Joan Jane Joe Tamara Anne Scott Chris Lana)
Your function should work on ANY list it is sent, not just the sample list.

b)   Write a function toppings which takes as parameters: a list of people's preferences, and the name of a person ; and returns the list of that person’s favorite toppings.  Some Examples:
(toppings PizzaParty ‘Robert)    should produce   (pepperoni)
(toppings PizzaParty ‘Tamara)   should produce     (ham pineapple)
(toppings PizzaParty ‘Mike)      should produce     ()

Note1:   If the person named is not in the list, then the empty list should be returned.
Note2:   The person’s name needs to be quoted, even though the names are not quoted in the file.
Note3:   Your function should work on ANY list it is sent, not just the sample list.

c)   Write a function whichpeople that takes as parameters, the preferences list and the name of a topping.    The function should return a list of all those people who have that topping in the favorite topping list.

(whichPeople PizzaParty ‘pepperoni)  should produce  (Robert Jane Scott Chris)
Note1:  The topping needs to be quoted, even though it is not quoted in the file.
Note2: that each name and each topping do NOT have quotes in front of them here.  This is because they are not evaluated here.
Note3:   Your function should work on ANY list it is sent, not just the sample list.

Notes/clarifications:

• I suggest you copy and paste the variable declaration into the file you are loading with your code.
• You can load a file by saying :  (load "code")    where "code" is the name of the file.
•  It is up to you to determine how to test your programs.
• You may wish to write some auxiliary functions to help you with the ones above.  (In other words, if you want to write more functions than those listed, go right ahead.)

### Handin:

Handin method:  TBA