Adds functionality for set-nth.

Issue #578