rev 484 - trunk/docs/tutorial
SVN User <[email protected]> Fri, 14 May 2004 03:51:03 -0400
| Newsgroups | gmane.comp.lang.prothon.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: mark
Date: 2004-05-14 03:50:59 -0400 (Fri, 14 May 2004)
New Revision: 484
Modified:
trunk/docs/tutorial/tutorial3.htm
trunk/docs/tutorial/tutorial4.htm
Log:
more typos
Modified: trunk/docs/tutorial/tutorial3.htm
===================================================================
--- trunk/docs/tutorial/tutorial3.htm 2004-05-14 07:30:11 UTC (rev 483)
+++ trunk/docs/tutorial/tutorial3.htm 2004-05-14 07:50:59 UTC (rev 484)
@@ -50,7 +50,7 @@
point numbers are standard "C double" 64-bit IEEE floating
point numbers. You can tell a floating point number from an integer
by the presence of a decimal point, such as in "1.0" or the
- exponent symbol "e" and in "1e3".. </p>
+ exponent symbol "e" as in "1e3".</p>
<p>Most standard representations of floating point or scientific numbers
will work in Prothon with one exception. That exception is that the
number may not end in a period. When you type a number that ends in
@@ -106,7 +106,7 @@
last type of string is useful for entering multiple lines of text. You
use three quotes instead of one and it will include line endings.</p>
<pre>x = """ line 1
- line 2 """\</pre>
+ line 2 """</pre>
<p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="concat"></a></font>Strings
can be added together (concatenated) just like numbers. You can actually
add a string on the left to anything on the right and Prothon will convert
@@ -125,7 +125,8 @@
can also access slices of more than one char by using the form [m:n]
where m specifies the index of the first char and n is one greater than
the index of the last character. You can also add a third number to
- specify a step size to get non-contiguous characters:</p>
+ specify a step size to get non-contiguous characters and/or a negative
+ number to access the chars in reverse:</p>
<pre>>>> x = "abcdefghijklm"
abcdefghijklm
>>> print x[2], x[1:3], x[0:10:2], x[12:-1:-1]
@@ -134,14 +135,15 @@
you use a negative number for an index, it is treated as an offset from
the end of the string. The number -1 will index the last character in
the string, -2 will access the next to last, etc. One way to think of
- this is that the index points to the left side of the char and that
- zero points to the left of the first char and the right of the last
+ this is that the index points to the left side of the char and zero
+ points both to the left of the first char and the right of the last
char.</p>
<p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="defind"></a></font>One
last trick to use with indexes is to leave the number out and use the
- defaults. The first index will default to the leftmost char if the third
- is positive and to the rightmost position if the third is negative.
- The second will default to the opposite end of the string from the first:</p>
+ defaults. The first index will default to the first char if the third
+ number is positive or missing and to the last position if the third
+ is negative. The second will default to the opposite end of the string
+ from the first:</p>
<pre>>>> x = "abcdef"
abcdef
>>> print x[-2], x[-3:-1], x[3:], x[:2], x[:2:-1], x[-1:-1:-1], x[:]
Modified: trunk/docs/tutorial/tutorial4.htm
===================================================================
--- trunk/docs/tutorial/tutorial4.htm 2004-05-14 07:30:11 UTC (rev 483)
+++ trunk/docs/tutorial/tutorial4.htm 2004-05-14 07:50:59 UTC (rev 484)
@@ -155,9 +155,9 @@
>>></pre>
<p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="tufun"></a></font>You
can do anything with a tuple that you can do with a list except assign
- to them on the left side of an assignment statement, use the del command
- on them, or use any mutable function on them. These functions are easy
- to tell because they are the ones that end with an exclamation mark.</p>
+ to it on the left side of an assignment statement, use the del command
+ on it, or use any mutable function on it. These functions are easy to
+ tell because they are the ones that end with an exclamation mark.</p>
<pre>>>> tuple = (1,2,3)
(1, 2, 3)
>>> tuple + (4,5,6)
@@ -199,12 +199,12 @@
{1:2, 'b':'c', 3:'a'} {} {1:2}
>>></pre>
<p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="dictmutable"></a></font>Dictionaries
- are accessed to look up values much like lists and tuples, but any object
- can be used as the index since the index is the key to be searched for.
- There are no slices in dictionaries so there is no equivalent of multiple
- indexes. Since dictionaries are mutable they can be on the left side
- of an assignment statement and the del command can be used to remove
- key/value pairs.</p>
+ are accessed to look up values much like lists and tuples, but any immutable
+ object can be used as the index since the index is the key to be searched
+ for. There are no slices in dictionaries so there is no equivalent of
+ multiple indexes. Since dictionaries are mutable they can be on the
+ left side of an assignment statement and the del command can be used
+ to remove key/value pairs.</p>
<pre>>>> dict = {1:2, 3:'a', 'b':'c'}
{1:2, 'b':'c', 3:'a'}
>>> dict[1] # simple lookup