Refactored Vector.apply(length, initializer) replacing excessive code with library method

(also removed unused variable ```ans``` as minor change)
Merge pull request #756 from cdshines/patch-1

Refactored Vector.apply(length, initializer) replacing excessive code with library method