CS 330 Lecture 22 – Haskell
Agenda
- what ?s
- exam post mortem
- hello, Haskell
- what we mean by functional
- Haskell examples
TODO
- Read chapters 3 and 4 of Learn You a Haskell for Great Good! On a 1/4 sheet, answer these questions:
- What’s the type signature of the
max
function as reported by:t
? What does the signature mean? - When defining a function with pattern matching, how do you signify that you don’t plan to reference a parameter or a part of a parameter and do not wish to bind it to a name?
- Write a function
clamp
and its type signature. It accepts a lower bound, an upper bound, and a value, allDouble
s. If the value is in the given range, it returns it without modification. If it’s outside, it returns the appropriate bound.
- What’s the type signature of the
Note
Today we begin our foray into functional programming. We’ll discuss what is usually meant by the term functional programming. Haskell is a great example of a language that sticks closely to functional ideals, but it’s different enough that we will spend today examining its syntax, function structure, and common data types.
Code
fs.hs
insides :: [a] -> [a]
insides list = tail (init list)