1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Comparison Operators</title><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><link rel="home" href="index.html" title="Manual do Genius"><link rel="up" href="ch06.html" title="Chapter 6. Programming with GEL"><link rel="prev" href="ch06s03.html" title="Sums and Products"><link rel="next" href="ch06s05.html" title="Global Variables and Scope of Variables"></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">Comparison Operators</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch06s03.html">Prev</a> </td><th width="60%" align="center">Chapter 6. Programming with GEL</th><td width="20%" align="right"> <a accesskey="n" href="ch06s05.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-comparison-operators"></a>Comparison Operators</h2></div></div></div><p lang="en">
The following standard comparison operators are supported in GEL and have the obvious meaning:
<code class="literal">==</code>, <code class="literal">>=</code>,
<code class="literal"><=</code>, <code class="literal">!=</code>,
<code class="literal"><></code>, <code class="literal"><</code>,
<code class="literal">></code>. They return <code class="constant">true</code> or
<code class="constant">false</code>.
The operators
<code class="literal">!=</code> and <code class="literal"><></code> are the same
thing and mean "is not equal to".
GEL also supports the operator
<code class="literal"><=></code>, which returns -1 if left side is
smaller, 0 if both sides are equal, 1 if left side is larger.
</p><p lang="en">
Normally <code class="literal">=</code> is translated to <code class="literal">==</code> if
it happens to be somewhere where GEL is expecting a condition such as
in the if condition. For example
</p><pre lang="en" class="programlisting">if a=b then c
if a==b then c
</pre><p lang="en">
are the same thing in GEL. However you should really use
<code class="literal">==</code> or <code class="literal">:=</code> when you want to compare
or assign respectively if you want your code to be easy to read and
to avoid mistakes.
</p><p lang="en">
All the comparison operators (except for the
<code class="literal"><=></code> operator, which
behaves normally), are not strictly binary operators, they can in fact
be grouped in the normal mathematical way, e.g.:
(<code class="literal">1<x<=y<5</code>) is
a legal boolean expression and means just what it should, that is
(1<x and x≤y and y<5)
</p><p lang="en">
To build up logical expressions use the words <code class="literal">not</code>,
<code class="literal">and</code>, <code class="literal">or</code>, <code class="literal">xor</code>.
The operators <code class="literal">or</code> and <code class="literal">and</code> are
special beasts as they evaluate their arguments one by one, so the usual trick
for conditional evaluation works here as well. For example, <code class="literal">1 or a=1</code> will not set
<code class="literal">a=1</code> since the first argument was true.
</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch06s03.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch06.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch06s05.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Sums and Products </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Global Variables and Scope of Variables</td></tr></table></div></body></html>
|