With 99 questions Problem 3 wants a function elementAt that will take a list and an index and return the element for that index. One very odd version in the solutions is
elementAt xs n = head $ foldr ($) xs $ replicate (n - 1) tail
So the function "passed" is ($) and the accumulator "seed" is the incoming list xs and the list to be worked on is (replicate (n-1) tail) which . . . and I can't fathom what's happening -- other than perhaps (replicate (n-1) (tail xs))
elementAt [1,2] 2 would be
foldr ($) [1,2] (replicate 1 (tail [1,2])
foldr ($) [1,2] ([2])
. . . now I'm lost. Can someone walk me through this?
LB