Debian Codegraph @

help/cs/html/ch07s02.html

raw symbols SCIP
1 <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Syntaxe v nejvyšší úrovni</title><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><link rel="home" href="index.html" title="Příručka k aplikaci Genius"><link rel="up" href="ch07.html" title="Chapter 7. Pokročilé programování v jazyce GEL"><link rel="prev" href="ch07.html" title="Chapter 7. Pokročilé programování v jazyce GEL"><link rel="next" href="ch07s03.html" title="Vracení funkcí"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Syntaxe v nejvyšší úrovni</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch07.html">Prev</a> </td><th width="60%" align="center">Chapter 7. Pokročilé programování v jazyce GEL</th><td width="20%" align="right"> <a accesskey="n" href="ch07s03.html">Next</a></td></tr></table><hr></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="genius-gel-toplevel-syntax"></a>Syntaxe v nejvyšší úrovni</h2></div></div></div><p lang="en">
2 The syntax is slightly different if you enter statements on
3 the top level versus when they are inside parentheses or
4 inside functions. On the top level, enter acts the same as if
5 you press return on the command line. Therefore think of programs
6 as just a sequence of lines as if they were entered on the command line.
7 In particular, you do not need to enter the separator at the end of the
8 line (unless it is part of several statements inside
9 parentheses). When a statement does not end with a separator on the
10 top level, the result is printed after being executed.
11 </p><p lang="en">
12 For example,
13 </p><pre lang="en" class="programlisting">function f(x)=x^2
14 f(3)
15 </pre><p lang="en">
16 will print first the result of setting a function (a representation of
17 the function, in this case <code class="computeroutput">(`(x)=(x^2))</code>)
18 and then the expected 9. To avoid this, enter a separator
19 after the function definition.
20 </p><pre lang="en" class="programlisting">function f(x)=x^2;
21 f(3)
22 </pre><p lang="en">
23 If you need to put a separator into your function then you have to surround with
24 parenthesis. For example:
25 </p><pre lang="en" class="programlisting">function f(x)=(
26 y=1;
27 for j=1 to x do
28 y = y+j;
29 y^2
30 );
31 </pre><p lang="en">
32 </p><p lang="en">
33 The following code will produce an error when entered on the top
34 level of a program, while it will work just fine in a function.
35 </p><pre lang="en" class="programlisting">if Something() then
36 DoSomething()
37 else
38 DoSomethingElse()
39 </pre><p lang="en">
40 </p><p lang="en">
41 The problem is that after <span class="application">Genius Mathematics Tool</span> sees the end of line after the
42 second line, it will decide that we have whole statement and
43 it will execute it. After the execution is done, <span class="application">Genius Mathematics Tool</span> will
44 go on to the next
45 line, it will see <code class="literal">else</code>, and it will produce
46 a parsing error. To fix this, use parentheses. <span class="application">Genius Mathematics Tool</span> will not
47 be satisfied until it has found that all parentheses are closed.
48 </p><pre lang="en" class="programlisting">if Something() then (
49 DoSomething()
50 ) else (
51 DoSomethingElse()
52 )
53 </pre><p lang="en">
54 </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch07.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch07.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch07s03.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 7. Pokročilé programování v jazyce GEL </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Vracení funkcí</td></tr></table></div></body></html>