<div dir="ltr">With <a href="https://wiki.haskell.org/99_questions/Solutions/3">99 questions</a> 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<div><br></div><div>elementAt xs n = head $ foldr ($) xs $ replicate (n - 1) tail<br></div><div><br></div><div>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))</div><div><br></div><div>elementAt [1,2] 2 would be </div><div><br></div><div>foldr ($) [1,2] (replicate 1 (tail [1,2])</div><div>foldr ($) [1,2] ([2])</div><div><br></div><div>. . . now I'm lost. Can someone walk me through this?</div><div><br></div><div>LB</div></div>