Permalink
Browse files

Update lessons

  • Loading branch information...
1 parent 5749a77 commit 71955596cc91ee68d79617139e9642d901d6b9f9 @OCamlPro-Bozman OCamlPro-Bozman committed Mar 7, 2013
@@ -4,15 +4,18 @@ <h3>Sequence of expressions</h3>
mainstream languages. So you'd better be aware of a few things before digging
any deeper.</p>
+<br />
<p>To begin with, you should know that a proper command must normally ends with
<em>';;'</em> to be processed by the top-level. This tutorial automatically adds
the double semicolon as soon as you hit enter but the normal top-level won't.
The double semicolon is only required when interacting with the top level
interpreter and as such is not part of OCaml syntax.</p>
+<br />
<p>What <em>is</em> part of OCaml syntax, though, is the simple semicolon
<em>';'</em> which is commonly used as an expression terminator, except that in
OCaml it's a <b>separator</b>. In other words, you must not write <code>expr1;
expr2;</code> but <code>expr1 ; expr2</code>.</p>
+<br/ >
<p>You may now enter <code>next ()</code> to check your understanding.</p>
@@ -1,16 +1,16 @@
<h3>Exercise: Get the Punctuation Right!</h3>
-<p>Let's see if you got this right. Here is a sequence of erroneous
+<p>Let's see if you got this right. Here is a sequence of <strong>erroneous</strong>
commands. Your task is to fix all of them in order to get the correct
answer at the end.</p>
-
+<br />
<p><code>let fernand = "King of Castille";</code></p>
-
+<br/>
<p><code>let rodrigue = "The cid"; let diegue = "cid's father"</code></p>
-
+<br/>
<p><code>characters = [ fernand;; rodrigue;; diegue ]</code></p>
-
+<br/>
<p><code>rodrigue.[4] <- 'C' ; diegue.[0] <- rodrigue.[4] ;</code></p>
-
+<br/>
<p><code>characters</code></p>
@@ -2,17 +2,22 @@ <h3>The <em>let</em> keyword</h3>
<p>The other source of confusion for newcomers is the <em>let</em> keyword
which acts differently in the toplevel than in normal OCaml expressions.</p>
+<br />
-<p>In the toplevel <code>let x = 1</code> binds the name <em>x</em> to the
-integer 1 as seen in <code>lesson 2</code>. If x was already bound to something
-it's previous binding is lost:</p>
+<p>In the toplevel <code>let x = 1</code> binds the name <code>x</code> to the
+integer 1 as seen in <code>lesson 2</code>. If <em>x</em> was already bound to something
+it's previous binding is lost:</p>
<code>let x = "I am now a string!"</code>
+<br /><br />
<p>The <em>let</em> keyword is also used to form an expression in which a name
-is given to some value temporarily, for the evaluation of a subexpression only:
-<code>let x = 41 in x + 1</code>. The value of <em>x</em> is <em>41</em> during
+is given to some value temporarily, for the evaluation of a subexpression only:<br />
+<code>let x = 41 in x + 1</code><br />
+
+ The value of <em>x</em> is <em>41</em> during
the evaluation of <em>x + 1</em> only; the global binding of <em>x</em> to
<code>"I am now a string!"</code> is preserved.</p>
+<br />
<p>See what <code>x</code> is evaluated to now, and type <code>next ()</code>
for a little practice.</p>
@@ -3,7 +3,7 @@ <h3>Parentheses</h3>
<p>With regard to grouping expression or enforcing order of evaluation,
OCaml syntax is surprisingly easy: you can use pervasively either parentheses
of <em>begin</em>/<em>end</em> keywords.</p>
-
+<br />
<p>Example grouping expressions in an <em>if</em> form:</p>
<pre><code>if 1+2 = 3 then (
print_string "did you knew that?\n" ;
@@ -15,6 +15,7 @@ <h3>Parentheses</h3>
you won't find this often!):</p>
<code>begin 1 + 2 end * 3</code>
+<br /><br />
<p>Also, as function application takes precedence over infix operators you will
frequently uses parentheses to make explicit the expected evaluation order, as
in: <code>square (1 + 1)</code> since <code>square 1+1</code> would yield

0 comments on commit 7195559

Please sign in to comment.