Returns a function that gets the nth element of an array