Sophie

Sophie

distrib > Fedora > 13 > i386 > by-pkgid > c32d98fa79ce2d1848954c3d039e7a21 > files > 98

Io-language-devel-20080330-1.fc13.i686.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Io Programming Guide</title>
<META HTTP-EQUIV="EXPIRES" CONTENT=0>
<link rel="stylesheet" href="docs.css">
</head>
<body>

<h1>The Io Tutorial</h1>
<p>
<br>

<table style="width:47em">
<tr>
<td valign=top style="width:33%">

<div class=indexSection><a href="#Introduction">Introduction</a></div>
<div class=indexItem><a href="#Introduction-Perspective">Math</a></div>
<div class=indexItem><a href="#Introduction-Getting-Started">Variables</a></div>
<div class=indexItem><a href="#Introduction-Downloading">Conditions</a></div>
<div class=indexItem><a href="#Introduction-Installing">Lists</a></div>
<div class=indexItem><a href="#Introduction-Binaries">Loops</a></div>
<div class=indexItem><a href="#Introduction-Running-Scripts">Strings</a></div>

</td>
</tr>
</table>

<p>

<h2>Introduction<a name="Introduction"></a></h2>
<div class=indent>
	
<div class=quote>
	Begin at the beginning and go on till you come to the end: then stop.<br>
	- the King, Alice in Wonderland
</div>

This is a quick overview of Io intended for folks that already know how to program.<p>
After compiling Io, run the io executable in the binaries folder. You should get a prompt like this:
<pre>
IoVM version 20031123
Io>
</pre>
The following is an annotated transcript of a CLI session that will walk through some examples:
<p>
<h3>Basic Math</h3>

<pre>
Io> 1+1
==> 2

Io> 2 sin
==> 0.909297

Io> 2 sqrt
==> 1.414214
</PRE>

<h3>Variables</h3>

<PRE>
Io> a := 1
==> 1

Io> a
==> 1

Io> b := 2 * 3
==> 6

Io> a + b
==> 7
</PRE>

<h3>Conditions</h3>
<PRE>
Io> a := 2

Io> if(a == 1) then(writeln("a is one")) else(writeln("a is not one"))
a is not one

Io> if(a == 1, writeln("a is one"), writeln("a is not one"))
a is not one
</PRE>

<h3>Lists</h3>

<PRE>
Io> d := List clone append(30, 10, 5, 20)    
==> list(30, 10, 5, 20)   

Io> d size
==> 4

Io> d print
==> list(30, 10, 5, 20)

Io> d := d sort
==> list(5, 10, 20, 30)

Io> d first
==> 5

Io> d last
==> 30

Io> d at(2)
==> 20

Io> d remove(30)
==> list(5, 10, 20)

Io> d atPut(1, 123)
==> list(5, 123, 20)
</PRE>

<h3>Loops</h3>
<PRE>
Io> for(i, 1, 10, write(i, " "))
1 2 3 4 5 6 7 8 9 10 

Io> d foreach(i, v, writeln(i, ": ", v))
0: 5
1: 123
3: 20
</PRE>

<h3>Strings</h3>

<PRE>
Io> a := "foo"
==> "foo"

Io> b := "bar"
==> "bar"

Io> c := a .. b
==> "foobar"

Io> c at(0)
==> 102

Io> c at(0) asCharacter
==> "f"

Io> s := "this is a test"
==> "this is a test"

Io> words := s split(" ", "\t") print
"this", "is", "a", "test"

Io> s findSeq("is")
==> 2

Io> s findSeq("test")
==> 10

Io> s slice(10)
==> "test"

Io> s slice(2, 10)
==> "is is a "

</pre>

</ul>
Also see: <a href=http://www.quag.geek.nz/io/getting-started/>Quag's Getting Started Tutorial</a>.
<br>
<br>