annotate scripts/general/colon.m @ 12718:01980844dc9c stable

colon.m: Stop issuing error if called accidentally with no arguments. * colon.m: Check nargin != 0 before issuing error.
author Rik <octave@nomad.inbox5.com>
date Wed, 08 Jun 2011 10:41:40 -0700
parents fd0a3ac60b0e
children 9e7ebbaf69ff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 10821
diff changeset
1 ## Copyright (C) 2008-2011 David Bateman
8213
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
2 ##
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
3 ## This file is part of Octave.
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
4 ##
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
8 ## your option) any later version.
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
9 ##
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
13 ## General Public License for more details.
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
14 ##
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
18
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
19 ## -*- texinfo -*-
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 9245
diff changeset
20 ## @deftypefn {Function File} {@var{r} =} colon (@var{a}, @var{b})
8213
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
21 ## @deftypefnx {Function File} {@var{r} =} colon (@var{a}, @var{b}, @var{c})
9051
1bf0ce0930be Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents: 8221
diff changeset
22 ## Method of a class to construct a range with the @code{:} operator. For
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
23 ## example:
8213
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
24 ##
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
25 ## @example
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
26 ## @group
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
27 ## a = myclass (@dots{})
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
28 ## b = myclass (@dots{})
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
29 ## c = a : b
8221
06094fa570a3 Add some documentation for the OOP code of Octave
David Bateman <dbateman@free.fr>
parents: 8213
diff changeset
30 ## @end group
8213
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
31 ## @end example
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
32 ##
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
33 ## @seealso{class, subsref, subsasgn}
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
34 ## @end deftypefn
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
35
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
36 function r = colon (varargin)
12718
01980844dc9c colon.m: Stop issuing error if called accidentally with no arguments.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
37 if (nargin != 0)
01980844dc9c colon.m: Stop issuing error if called accidentally with no arguments.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
38 error ("colon: not defined for class \"%s\"", class(varargin{1}));
01980844dc9c colon.m: Stop issuing error if called accidentally with no arguments.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
39 endif
8213
d5e08881bba8 Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
diff changeset
40 endfunction