comparison doc/interpreter/func.txi @ 32489:a4506463f341 stable

doc: grammarcheck Octave manual before 9.1 release. * doc/interpreter/func.txi, doc/interpreter/numbers.txi, doc/interpreter/octave.texi, doc/interpreter/plot.txi, doc/interpreter/sparse.txi, doc/interpreter/vectorize.txi, scripts/miscellaneous/jupyter_notebook.m, scripts/plot/draw/stemleaf.m: grammarcheck Octave manual before 9.1 release.
author Rik <rik@octave.org>
date Thu, 23 Nov 2023 20:30:44 -0800
parents 9583d971e603
children 2e484f9f1f18
comparison
equal deleted inserted replaced
32488:d7a3ed7f2fdc 32489:a4506463f341
1985 It should be noted that mixing command syntax and binary operators can 1985 It should be noted that mixing command syntax and binary operators can
1986 create apparent ambiguities with mathematical and logical expressions that 1986 create apparent ambiguities with mathematical and logical expressions that
1987 use function syntax. For example, all three of the statements 1987 use function syntax. For example, all three of the statements
1988 1988
1989 @example 1989 @example
1990 @group
1990 arg1 - arg2 1991 arg1 - arg2
1991 arg1 -arg2 1992 arg1 -arg2
1992 arg1-arg2 1993 arg1-arg2
1994 @end group
1993 @end example 1995 @end example
1994 1996
1995 @noindent 1997 @noindent
1996 could be intended by a user to be subtraction operations between 1998 could be intended by a user to be subtraction operations between
1997 @code{arg1} and @code{arg2}. The first two, however, could also have been 1999 @code{arg1} and @code{arg2}. The first two, however, could also have been
1998 meant as a command syntax call to function @code{arg1}, in the first case 2000 meant as a command syntax call to function @code{arg1}, in the first case
1999 with options @code{-} and @code{arg2}, and in the second case with option 2001 with options @code{-} and @code{arg2}, and in the second case with option
2000 @code{-arg2}. 2002 @option{-arg2}.
2001 2003
2002 Octave uses whitespace to interpret such expressions according to the 2004 Octave uses whitespace to interpret such expressions according to the
2003 following rules: 2005 following rules:
2004 2006
2005 @itemize @bullet 2007 @itemize @bullet
2011 arg1 arg2 arg3 ... argn 2013 arg1 arg2 arg3 ... argn
2012 @end example 2014 @end example
2013 2015
2014 @item 2016 @item
2015 Statements without any whitespace are always treated as function syntax: 2017 Statements without any whitespace are always treated as function syntax:
2016 @example 2018
2019 @example
2020 @group
2017 arg1+arg2 2021 arg1+arg2
2018 arg1&&arg2||arg3 2022 arg1&&arg2||arg3
2019 arg1+=arg2*arg3 2023 arg1+=arg2*arg3
2024 @end group
2020 @end example 2025 @end example
2021 2026
2022 @item 2027 @item
2023 If the first symbol is a constant (or special-valued named constant pi, i, 2028 If the first symbol is a constant (or special-valued named constant pi, i,
2024 I, j, J, e, NaN, or Inf) followed by a binary operator, the statement is 2029 I, j, J, e, NaN, or Inf) followed by a binary operator, the statement is
2025 treated as function syntax regardless of any whitespace or what follows the 2030 treated as function syntax regardless of any whitespace or what follows the
2026 second symbol: 2031 second symbol:
2027 @example 2032
2033 @example
2034 @group
2028 7 -arg2 2035 7 -arg2
2029 pi+ arg2 2036 pi+ arg2
2030 j * arg2 -arg3 2037 j * arg2 -arg3
2038 @end group
2031 @end example 2039 @end example
2032 2040
2033 @item 2041 @item
2034 If the first symbol is a function or variable and there is no whitespace 2042 If the first symbol is a function or variable and there is no whitespace
2035 separating the operator and the second symbol, the statement is treated 2043 separating the operator and the second symbol, the statement is treated
2036 as command syntax: 2044 as command syntax:
2037 @example 2045
2046 @example
2047 @group
2038 arg1 -arg2 2048 arg1 -arg2
2039 arg1 &&arg2 ||arg3 2049 arg1 &&arg2 ||arg3
2040 arg1 +=arg2*arg3 2050 arg1 +=arg2*arg3
2051 @end group
2041 @end example 2052 @end example
2042 2053
2043 @item 2054 @item
2044 Any other whitespace combination will result in the statement being treated 2055 Any other whitespace combination will result in the statement being treated
2045 as function syntax. 2056 as function syntax.
2046 @end itemize 2057 @end itemize
2047 2058
2048 Note 1: If a special-valued named constant has been redefined as a 2059 Note 1: If a special-valued named constant has been redefined as a
2049 variable, the interpreter will still process the statement with function 2060 variable, the interpreter will still process the statement with function
2050 syntax. 2061 syntax.
2051 2062
2052 Note 2: Attempting to use a variable as @code{arg1} in a command being 2063 Note 2: Attempting to use a variable as @code{arg1} in a command being
2053 processed as command syntax will result in an error. 2064 processed as command syntax will result in an error.
2054 2065
2055 2066
2056 @node Organization of Functions 2067 @node Organization of Functions
2057 @section Organization of Functions Distributed with Octave 2068 @section Organization of Functions Distributed with Octave