Share inference logic across arr and Values

This commit has the previous push in it as well. The new commits start at the add-loop-function commit. The commits for merging the list logic are in progress but need more unit tests for all the issues I uncovered.