Implement a general solution for the partition a sequence problem using loop recur.