Write the following. Include a type declaration for each value or function. Functions should have the most general types possible, so [a] -> a is preferable to [Char] -> Char. You have considerable freedom in your definitions, but you should not define a function with one word (because there happens to be an identical function built in) or define a value directly (instead of constructing it with, e.g., a list comprehension).
A function antepenultimate that takes a list and returns the third-to-last element of that set.
A function indexOf that takes an element and a list and returns the zero-based index where that element first appears (or -1 if it doesn't).
A function upperCase that takes a letter and returns the upper case version of that letter. You are not responsible for non-letter input.
A function studlyCaps that takes a string of words (with spaces), smashes them together, and capitalizes each word but the first.
A function duplicates that takes a list and returns true if any two elements in the list are the same.
A list of pairs rolls showing all possible rolls of two six-sided dice.
A function counts that takes a list and returns a list of pairs, with each pair containing an element and the number of times it appears.
A list of pairs sums, showing how often each sum appears when rolling two six-sided dice.
The GHCI session below shows these functions and values in action. Your functions must work for other examples, too!
Prelude>:l a1
[1 of 1] Compiling Main ( a1.hs, interpreted )
Ok, modules loaded: Main.
*Main> antepenultimate "abcdef"
'd'
*Main> antepenultimate [1..10]
8
*Main> indexOf 'c' "abcdef"
2
*Main> upperCase 'c'
'C'
*Main> studlyCaps "that which must not be alluded to"
"thatWhichMustNotBeAlludedTo"
*Main> duplicates "abcdef"
False
*Main> duplicates "abcdcf"
True
*Main> rolls
[(1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(2,1),(2,2),(2,3),(2,4),(2,5),(2,6),(3,1),(3,2),(3,3),(3,4),(3,5),(3,6),(4,1),(4,2),(4,3),(4,4),(4,5),(4,6),(5,1),(5,2),(5,3),(5,4),(5,5),(5,6),(6,1),(6,2),(6,3),(6,4),(6,5),(6,6)]
*Main> counts "where the elite meet to eat reheated meaty treats"
[('w',1),('l',1),('i',1),('o',1),('h',3),('d',1),('m',2),('y',1),(' ',8),('r',3),('e',13),('a',4),('t',9),('s',1)]
*Main> sums
[(2,1),(3,2),(4,3),(5,4),(6,5),(7,6),(8,5),(9,4),(10,3),(11,2),(12,1)]
*Main>
Also identify the pet language you've chosen, along with when, where, and by whom it was invented. For example, Java was developed in the early 1990s at Sun Microsystems by a team led by James Gosling.
Hand in a a1.hs containing all of your code and a Google word processing document lingo1 containing your pet language information.