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

(also removed unused variable ```ans``` as minor change)