Use reduce instead of recursion in ap and bind