Chapter 6. Programování s jazykem GEL

Table of Contents

Podmínky
Smyčky
Smyčky while
Smyčky for
Smyčky foreach
Break a continue
Součty a součiny
Porovnávací operátory
Globální proměnné a působnost proměnných
Proměnné parametrů
Návrat hodnot
Reference
L-hodnoty

Podmínky

Syntax:

if <expression1> then <expression2> [else <expression3>]

If else is omitted, then if the expression1 yields false or 0, NULL is returned.

Examples:

if(a==5)then(a=a-1)
if b<a then b=a
if c>0 then c=c-1 else c=0
a = ( if b>0 then b else 1 )

Note that = will be translated to == if used inside the expression for if, so

if a=5 then a=a-1

will be interpreted as:

if a==5 then a:=a-1