1 ## Copyright (C) 1996-2012 Kurt Hornik
3 ## This file is part of Octave.
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ## General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
20 ## @deftypefn {Function File} {} blanks (@var{n})
21 ## Return a string of @var{n} blanks, for example:
28 ## Attr Name Size Bytes Class
29 ## ==== ==== ==== ===== =====
36 ## Author: Kurt Hornik <Kurt.Hornik@wu-wien.ac.at>
39 function s = blanks (n)
43 elseif (! (isscalar (n) && n == fix (n) && n >= 0))
44 error ("blanks: N must be a non-negative integer");
47 ## If 1:n is empty, the following expression will create an empty
48 ## character string. Otherwise, it will create a row vector.
54 ## There really isn't that much to test here
55 %!assert(blanks (0), "")
56 %!assert(blanks (5), " ")
57 %!assert(blanks (10), " ")
59 %% Test input validation
62 %!error blanks (ones (2))