Hi,
I think your interpretation of (replicate (n-1) tail) is wrong. First note that tail is not applied to anything, is just the function tail.
So replicate (n-1) tail is [tail, tail, tail, .... , tail]. For example
replicate 3 tail = [tail, tail, tail]
Note that if you try to compute this in Haskell it won't be able to show that result, because there is no "show" defined for something that has the type of a list of functions.
Having said this, your example can now be written
elementAt [1,2] 2 =
= head (foldr ($) [1,2] (replicate 1 tail))
= head (foldr ($) [1,2] [tail])
= head (tail $ (foldr ($) [1,2] []))
= head (tail $ [1,2])
= head (tail ([1,2])) = head [2] = 2
For a more general example you can try
elementAt [1,2,3,4] 3 =
= head (foldr ($) [1,2,3,4] (replicate 2 tail))
= head (foldr ($) [1,2,3,4] [tail,tail])
= head (tail $ (foldr ($) [1,2,3,4] [tail]))
= head (tail $ tail $ [1,2,3,4])
= head (tail (tail [1,2,3,4)))
= head (tail [2,3,4]) = head [3,4] = 3
Cheers,
Ut