# Function application and function composition in Haskell

In the process of learning haskell, I've been trying to become comfortable with the function applicator ($) and function composition (.). Here is some code to show how they relate (and how they relate to using parenthesis to enforce order of operations): let dict = [(1,'a'),(2,'b'),(3,'c')] -- The following 3 lines of code are equivalent... snd . head . filter (\item@(k,v) -> k == 2)$ dict -- returns 'b'
snd $head$ filter (\item@(k,v) -> k == 2) dict -- returns 'b'
snd (head (filter (\item@(k,v) -> k == 2) dict)) -- return 'b'


• Lazy evaluation is huge in Haskell, and it lets you do things like this: let factorial n = product (take n [1..]) So here, we have an infinite list ([1..] creates a infinite list from 1 to infinity!) which from which the first n items are taken and passed to the product function. Awesomeness...