Chinese Whispers- The 2018 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
When writing a function, call it foo or bar so that it isn’t obvious!
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)
Polymorphism themed Qs:
- Finds the first element of any list
- Returns the number of elements in any list
- Reverses the elements of any list
- Takes two functions and combines them into a single composite function
- Takes a list and a predicate (true/false condition), and returns the elements of the list where the predicate is satisfied
- Checks if a number of the typeclass integral is even or odd
- Adds all elements of a list (assuming
(Num a) => a
) - Takes two numbers, adds them together, multiples by 75, and divides by the first number (how general can you make the type?)
- Applies a function over all elements in a list
- Inserts a value into any list given a particular index
- Combines two lists without using (++)
- Takes 3 numbers and calculates the Pythagoras theorem