Chinese Whispers Haskell Edition
Note: This is a group activity - a Haskell-version Chinese Whispers. The first person will write the FUNCTION (in Haskell), the next will write a DESCRIPTION (in English), etc. (Haskell, English, Haskell, …). Don’t worry about specifics - just use the data definition or syntax you are most familiar with, this is supposed to be fun
Remember to use a generic function name so you don’t give it away e.g. foo, bar
Pick one of the following problems (don’t tell anyone your choice!) and begin the cycle by writing it in Haskell to the best of your ability! (You’ve probably seen all these functions before, many are Prelude functions)
- Finds the first element of any list
- Puts the elements of a list into another list
- Counts the elements in a list
- Takes 3 numbers and calculates the Pythagoras theorem
- Finds the last element of any list
- Reverses the elements of a list
- Checks if a list is a set (no duplicates)
- Define a record type of your choice
- Finds the number of elements of any list
- Inserts an element into a list given an index (remember counting starts from 0)
- Removes duplicates in a list
- Inserts a value into a list given a particular index
- Finds if a number is even or odd
- Takes a list and a predicate, and returns the elements of the list where the predicate is satisfied
- Takes two functions and combines them into a single composite function
- Checks if a list is an ordered set (no duplicates, assumes
(Num a) => a
with all elements in order from increasing to decreasing) - Adds all elements of a list (assuming
(Num a) => a
) - Write the
filter
higher-order function - Takes two numbers, adds them together, multiples by 75, and divides by the first number
- Applies a function over all elements in a list