typesetting column vector

Note that you have extra space around your vector. You should probably using something like (pmatrix is part of the amsmath package)

\begin{pmatrix}a\\b\end{pmatrix}

The standard LaTeX \newcommand provides a way to have a single optional argument.

\newcommand*\colvec[3][]{
    \begin{pmatrix}\ifx\relax#1\relax\else#1\\\fi#2\\#3\end{pmatrix}
}

Note that you have to use \colvec[a]{b}{c} if you want three elements or \colvec{a}{b} if you want two.

Update
As per your request in the comments, here's one that takes any number of elements based on the number passed in the first argument.

\newcount\colveccount
\newcommand*\colvec[1]{
        \global\colveccount#1
        \begin{pmatrix}
        \colvecnext
}
\def\colvecnext#1{
        #1
        \global\advance\colveccount-1
        \ifnum\colveccount>0
                \\
                \expandafter\colvecnext
        \else
                \end{pmatrix}
        \fi
}

You use it exactly as you wanted, \colvec{5}{a}{b}{c}{d}{e}.


This is a more "TeX" approach. The number of rows is arbitrary. The columns are aligned right by default, but can be c or l as well:

\documentclass{article}

\makeatletter
\newcommand{\Spvek}[2][r]{%
  \gdef\@VORNE{1}
  \left(\hskip-\arraycolsep%
    \begin{array}{#1}\vekSp@lten{#2}\end{array}%
  \hskip-\arraycolsep\right)}

\def\vekSp@lten#1{\xvekSp@lten#1;vekL@stLine;}
\def\vekL@stLine{vekL@stLine}
\def\xvekSp@lten#1;{\def\temp{#1}%
  \ifx\temp\vekL@stLine
  \else
    \ifnum\@VORNE=1\gdef\@VORNE{0}
    \else\@arraycr\fi%
    #1%
    \expandafter\xvekSp@lten
  \fi}
\makeatother


\begin{document}
\[
\Spvek{1;-2} \quad \Spvek[l]{1;-2;3}\quad \Spvek[c]{1;-2;-3}\quad\Spvek{1;2;-3;4}
\]
\end{document}

Output will be:

enter image description here


I would to supplement the solution above about \Spvek by Peter B. Yes, it is a more "TeX" approach but pure "TeX" approach is in two lines only:

\def\spvec#1{\left(\vcenter{\halign{\hfil$##$\hfil\cr \spvecA#1;;}}\right)}
\def\spvecA#1;{\if;#1;\else #1\cr \expandafter \spvecA \fi}

$\spvec{1;2;3} + \spvec{1;2;-3;4} + \spvec{1;2}$

This solution will be work in LaTeX too because only TeX primitives are used here.