Matrix Elements VB-800 Instrukcja Użytkownika Strona 164

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 172
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 163
156 Appendix A7 Comparing Gauss and Ox syntax
A7.2.11 Conditional statements
if i == 1;
/* statements */
elseif i = 2;
/* statements */
else;
/* statements */
endif;
Again notice the difference in usage of
parenthesis and semi-colons.
if (i == 1)
{ /* statements */
}
else if (i = 2)
{ /* statements */
}
else
{ /* statements */
}
A7.2.12 Printing
In Gauss, a print statement consists of
a list of items to print. A space separates
the items, unless they are in parenthesis.
An expression without an equal sign is
also treated as a print statement.
Ox has a print and println function,
which gives the expressions to print, sep-
arated by a comma. Strings which con-
tain a format are not printed but apply to
the next expression.
A7.2.13 Functions
Gauss has procedures (proc), keywords
and single-line functions (fn). Proce-
dures may return many values; no values
can be returned in arguments. Local vari-
ables are declared with the local state-
ment.
proc(2) = foo(x, y);
local a,b;
/* code */
retp (a,b);
endp;
{c, d} = foo(1, 2);
Ox only has functions which may return
zero, one or more values. Values can
be also returned in arguments. Variables
are declared using decl. Variables have
a lifetime restricted to the brace level at
which they are declared.
foo(const x, const y,
const retb)
{ decl a,b;
/* code */
retb[0] = b;
return a;
}
c = foo(1, 2, &d);
Multiple returns are implemented as:
bar(const x)
{ decl a,b;
/* code */
return {a, b};
}
[c, d[0] ] = bar(1);
Przeglądanie stron 163

Komentarze do niniejszej Instrukcji

Brak uwag