stdlib: Implement subst function.