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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Chapter 5. Βασικά της GEL</title><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><link rel="home" href="index.html" title="Εγχειρίδιο Genius"><link rel="up" href="index.html" title="Εγχειρίδιο Genius"><link rel="prev" href="ch04s05.html" title="Γραφικές παραστάσεις επιφάνειας"><link rel="next" href="ch05s02.html" title="Χρήση μεταβλητών"></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">Chapter 5. Βασικά της GEL</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch04s05.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ch05s02.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="genius-gel"></a>Chapter 5. Βασικά της GEL</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="sect1"><a href="ch05.html#genius-gel-values">Τιμές</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch05.html#genius-gel-values-numbers">Αριθμοί</a></span></dt><dt><span class="sect2"><a href="ch05.html#genius-gel-values-booleans">Λογικές τιμές </a></span></dt><dt><span class="sect2"><a href="ch05.html#genius-gel-values-strings">Συμβολοσειρές</a></span></dt><dt><span class="sect2"><a href="ch05.html#genius-gel-values-null">Null</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch05s02.html">Χρήση μεταβλητών</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch05s02.html#genius-gel-variables-setting">Ορισμός μεταβλητών</a></span></dt><dt><span class="sect2"><a href="ch05s02.html#genius-gel-variables-built-in">Ενσωματωμένες μεταβλητές</a></span></dt><dt><span class="sect2"><a href="ch05s02.html#genius-gel-previous-result">Προηγούμενη μεταβλητή αποτελέσματος</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch05s03.html">Χρησιμοποίηση συναρτήσεων</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch05s03.html#genius-gel-functions-defining">Ορισμός συναρτήσεων</a></span></dt><dt><span class="sect2"><a href="ch05s03.html#genius-gel-functions-variable-argument-lists">Κατάλογοι ορισμάτων μεταβλητής</a></span></dt><dt><span class="sect2"><a href="ch05s03.html#genius-gel-functions-passing-functions">Πέρασμα συναρτήσεων σε συναρτήσεις</a></span></dt><dt><span class="sect2"><a href="ch05s03.html#genius-gel-functions-operations">Πράξεις σε συναρτήσεις</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch05s04.html">Διαχωριστικό</a></span></dt><dt><span class="sect1"><a href="ch05s05.html">Σχόλια</a></span></dt><dt><span class="sect1"><a href="ch05s06.html">Μετρικός υπολογισμός</a></span></dt><dt><span class="sect1"><a href="ch05s07.html">Κατάλογος τελεστών GEL</a></span></dt></dl></div><p>GEL σημαίνει γλώσσα επέκτασης Genius. Είναι η γλώσσα που χρησιμοποιείτε για να γράψετε προγράμματα στη Genius. Ένα πρόγραμμα στη GEL είναι απλά μια παράσταση που υπολογίζει έναν αριθμό. Το <span class="application">Εργαλείο μαθηματικών Genius</span> μπορεί να χρησιμοποιηθεί ως μια απλή αριθμομηχανή, ή ως ένα ισχυρό θεωρητικό εργαλείο αναζήτησης. Η σύνταξη πρέπει να έχει όσο πιο ρηχή καμπύλη μάθησης γίνεται, ειδικά για χρήση ως αριθμομηχανή.</p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="genius-gel-values"></a>Τιμές</h2></div></div></div><p>Οι τιμές στην GEL μπορεί να είναι <a class="link" href="ch05.html#genius-gel-values-numbers" title="Αριθμοί">αριθμοί</a>, <a class="link" href="ch05.html#genius-gel-values-booleans" title="Λογικές τιμές">Λογικές τιμές</a> ή <a class="link" href="ch05.html#genius-gel-values-strings" title="Συμβολοσειρές">συμβολοσειρές</a>. Η GEL θεωρεί επίσης <a class="link" href="ch08.html" title="Chapter 8. Πίνακες στη GEL">πίνακες</a> ως τιμές. Οι τιμές μπορεί να χρησιμοποιηθούν σε υπολογισμούς, εκχωρημένες σε μεταβλητές και να επιστραφούν από τις συναρτήσεις, μεταξύ άλλων χρήσεων.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="genius-gel-values-numbers"></a>Αριθμοί</h3></div></div></div><p lang="en">
Integers are the first type of number in GEL. Integers are written in the normal way.
</p><pre lang="en" class="programlisting">1234
</pre><p lang="en">
Hexadecimal and octal numbers can be written using C notation. For example:
</p><pre lang="en" class="programlisting">0x123ABC
01234
</pre><p lang="en">
Or you can type numbers in an arbitrary base using <code class="literal"><base>\<number></code>. Digits higher than 10 use letters in a similar way to hexadecimal. For example, a number in base 23 could be written:
</p><pre lang="en" class="programlisting">23\1234ABCD
</pre><p lang="en">
</p><p lang="en">
The second type of GEL number is rationals. Rationals are simply achieved by dividing two integers. So one could write:
</p><pre lang="en" class="programlisting">3/4
</pre><p lang="en">
to get three quarters. Rationals also accept mixed fraction notation. So in order to get one and three tenths you could write:
</p><pre lang="en" class="programlisting">1 3/10
</pre><p lang="en">
</p><p lang="en">
The next type of number is floating point. These are entered in a similar fashion to C notation. You can use <code class="literal">E</code>, <code class="literal">e</code> or <code class="literal">@</code> as the exponent delimiter. Note that using the exponent delimiter gives a float even if there is no decimal point in the number. Examples:
</p><pre lang="en" class="programlisting">1.315
7.887e77
7.887e-77
.3
0.3
77e5
</pre><p lang="en">
When Genius prints a floating point number it will always append a
<code class="computeroutput">.0</code> even if the number is whole. This is to indicate that
floating point numbers are taken as imprecise quantities. When a number is written in the
scientific notation, it is always a floating point number and thus Genius does not
print the <code class="computeroutput">.0</code>.
</p><p lang="en">
The final type of number in GEL is the complex numbers. You can enter a complex number as a sum of real and imaginary parts. To add an imaginary part, append an <code class="literal">i</code>. Here are examples of entering complex numbers:
</p><pre lang="en" class="programlisting">1+2i
8.01i
77*e^(1.3i)
</pre><p lang="en">
</p><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Important</h3><p>Κατά την εισαγωγή φανταστικών αριθμών, ένας αριθμός πρέπει να είναι μπροστά από το <code class="literal">i</code>. Αν χρησιμοποιήσετε <code class="literal">i</code> αυτό καθεαυτό, η Genius θα το ερμηνεύσει ως αναφορά στη μεταβλητή <code class="varname">i</code>. Αν χρειάζεται να αναφέρετε το <code class="literal">i</code> αυτό καθεαυτό, χρησιμοποιήστε <code class="literal">1i</code> στη θέση του.</p><p>Για να χρησιμοποιήσετε μικτή σημειογραφία κλάσματος με φανταστικούς αριθμούς, πρέπει να έχετε το μικτό κλάσμα σε παρενθέσεις. (δηλαδή, <strong class="userinput"><code>(1 2/5)i</code></strong>)</p></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="genius-gel-values-booleans"></a>Λογικές τιμές </h3></div></div></div><p>Η Genius επίσης υποστηρίζει εγγενείς λογικές τιμές. Οι δύο σταθερές λογικών τιμών ορίζονται ως <code class="constant">true</code> και <code class="constant">false</code>· αυτά τα αναγνωριστικά μπορούν να χρησιμοποιηθούν όπως κάθε άλλη μεταβλητή. Μπορείτε επίσης να χρησιμοποιήσετε τα αναγνωριστικά <code class="constant">True</code>, <code class="constant">TRUE</code>, <code class="constant">False</code> και <code class="constant">FALSE</code> ως παραλλαγές για τα παραπάνω.</p><p>Σε οποιαδήποτε θέση όπου αναμένεται παράσταση λογικών τιμών, μπορείτε να χρησιμοποιήσετε μια λογική τιμή ή οποιαδήποτε παράσταση παράγει ή έναν αριθμό ή μια λογική τιμή. Αν η Genius χρειάζεται να υπολογίσει έναν αριθμό ως λογική τιμή θα ερμηνεύσει το 0 ως <code class="constant">ψευδή</code> και οποιοδήποτε άλλο αριθμό ως <code class="constant">αληθή</code>.</p><p lang="en">
In addition, you can do arithmetic with Boolean values. For example:
</p><pre lang="en" class="programlisting">( (1 + true) - false ) * true
</pre><p lang="en">
is the same as:
</p><pre lang="en" class="programlisting">( (true or true) or not false ) and true
</pre><p lang="en">
Only addition, subtraction and multiplication are supported. If you mix numbers with Booleans in an expression then the numbers are converted to Booleans as described above. This means that, for example:
</p><pre lang="en" class="programlisting">1 == true
</pre><p lang="en">
always evaluates to <code class="constant">true</code> since 1 will be converted to <code class="constant">true</code> before being compared to <code class="constant">true</code>.
</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="genius-gel-values-strings"></a>Συμβολοσειρές</h3></div></div></div><p lang="en">
Like numbers and Booleans, strings in GEL can be stored as values inside variables and passed to functions. You can also concatenate a string with another value using the plus operator. For example:
</p><pre lang="en" class="programlisting">a=2+3;"The result is: "+a
</pre><p lang="en">
will create the string:
</p><pre lang="en" class="programlisting">The result is: 5
</pre><p lang="en">
You can also use C-like escape sequences such as <code class="literal">\n</code>,<code class="literal">\t</code>,<code class="literal">\b</code>,<code class="literal">\a</code> and <code class="literal">\r</code>. To get a <code class="literal">\</code> or <code class="literal">"</code> into the string you can quote it with a <code class="literal">\</code>. For example:
</p><pre lang="en" class="programlisting">"Slash: \\ Quotes: \" Tabs: \t1\t2\t3"
</pre><p lang="en">
will make a string:
</p><pre lang="en" class="programlisting">Slash: \ Quotes: " Tabs: 1 2 3
</pre><p lang="en">
Do note however that when a string is returned from a function, escapes are
quoted, so that the output can be used as input. If you wish to print the
string as it is (without escapes), use the
<a class="link" href="ch11s02.html#gel-function-print"><code class="function">print</code></a>
or
<a class="link" href="ch11s02.html#gel-function-printn"><code class="function">printn</code></a> functions.
</p><p lang="en">
In addition, you can use the library function <a class="link" href="ch11s02.html#gel-function-string"><code class="function">string</code></a> to convert anything to a string. For example:
</p><pre lang="en" class="programlisting">string(22)
</pre><p lang="en">
will return
</p><pre lang="en" class="programlisting">"22"
</pre><p lang="en">
Strings can also be compared with <code class="literal">==</code> (equal), <code class="literal">!=</code> (not equal) and <code class="literal"><=></code> (comparison) operators
</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="genius-gel-values-null"></a>Null</h3></div></div></div><p lang="en">
There is a special value called
<code class="constant">null</code>. No operations can be performed on
it, and nothing is printed when it is returned. Therefore,
<code class="constant">null</code> is useful when you do not want output from an
expression. The value <code class="constant">null</code> can be obtained as an expression when you
type <code class="literal">.</code>, the constant <code class="constant">null</code> or nothing.
By nothing we mean that if you end an expression with
a separator <code class="literal">;</code>, it is equivalent to ending it with a
separator followed by a <code class="constant">null</code>.
</p><p lang="en">
Example:
</p><pre lang="en" class="programlisting">x=5;.
x=5;
</pre><p lang="en">
</p><p>Κάποιες συναρτήσεις επιστρέφουν <code class="constant">null</code>, όταν καμιά τιμή δεν μπορεί να επιστραφεί ή όταν συμβαίνει ένα σφάλμα. Επίσης η <code class="constant">null</code> χρησιμοποιείται ως ένα κενό διάνυσμα ή πίνακας, ή μια κενή αναφορά.</p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch04s05.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="ch05s02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Γραφικές παραστάσεις επιφάνειας </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Χρήση μεταβλητών</td></tr></table></div></body></html>
|