Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ocaml-lessons/lesson1/step3/step.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h3>Operations on arrays</h3>

<br />
<p>To get the element number <code>i</code> of an array, you have two
ways to do this (don't forget, the first element has number <code>0</code>):</p>
ways to do this (don't forget, the first index of an Array is always <code>0</code>):</p>
<p><code>Array.get [| 42; 51; 32 |] 2 </code></p>

<p>or</p>
Expand Down
10 changes: 5 additions & 5 deletions ocaml-lessons/lesson1/step6/step.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<h3>Operations on Tuples</h3>

<p>A tuple consists of values (zero or more), enclosed in parentheses
and separated by commas. Note that you can have differents types for
each element, remember</p>
and separated by commas. Note that you can have different types for
each element:</p>
<p><code>(42, "John", true)</code></p>

<br />
<p>When you have a pair (a tuple with two elements), you can use some
predefined functions like get the first element:</p>
<p>When you have a pair (a tuple with two elements), you can use
predefined functions like getting the first element:</p>
<p><code>fst (42, "John")</code></p>

<br />
<p>Or the second element:</p>
<p>or the second element:</p>
<p><code>snd (42, "John")</code></p>
14 changes: 7 additions & 7 deletions ocaml-lessons/lesson2/step1/step.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<h3>Variables</h3>

<p>As in other languages, you can associate a name to a value. To do
that, we use the <code>let</code> syntax which associates the result
of some computation with a name:</p>

<p>Similarly to other languages, you can associate user defined variable names with values. To do
that, we use the <code>let</code> syntax which associates the result of value declaration, or some computation with a user defined variable name:</p>
<p><code>let a = 42</code></p>
<p><code>let x = 6 * 7</code></p>

<br />

<p>We can now check the value associated with <code>x</code> in the
<p>We can now check the value associated with <code>a</code>, or <code>x</code> in the
toplevel:</p>
<p><code>a</code></p>
<p><code>x</code></p>

<br />
<p>And we can use the name where we would like the value:</p>
<p><code>let y = x + 1</code></p>
<p>And we can just use the variable name where we would like to access the value:</p>
<p><code>let y = a + x</code></p>
10 changes: 5 additions & 5 deletions ocaml-lessons/lesson2/step2/step.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<h3>Mutable Variables</h3>

<p>In OCaml, you cannot change the value associated with a name after
<p>In OCaml, you cannot change the value associated with a variable after
its definition. Trying to do so will trigger a compilation error:</p>
<p><code>x <- x + 1</code></p>

<p>You will better understand the error message later.</p>

<br />
<p>If you really want to modify the value associated with a name, you
must use a trick. OCaml provides a function <code>ref</code> that
creates a special value that can be modified later (a reference):</p>
<p>If you really want to modify the value associated with a variable, you
must use a "trick". OCaml provides the <code>ref</code> syntax, that
creates a special value, that can be modified later (a reference):</p>
<p><code>let x = ref 42</code></p>

<br />
Expand All @@ -18,7 +18,7 @@ <h3>Mutable Variables</h3>
<p><code>x := 100 / 4</code></p>

<br />
<p>You can also access the value contained in the reference using the
<p>You can access the value contained in the reference using the
operator <code>!</code>:</p>

<p><code>let y = !x + 1</code></p>
2 changes: 1 addition & 1 deletion ocaml-lessons/lesson2/step3/step.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h3>Sequences and Printing</h3>
print_newline ()</code></pre>

<p>A more powerful method to print values
is <code>Printf.printf</code>, whose behavior is similar
is <code>Printf.printf</code>, which is similar
to <code>printf</code> in C:</p>

<p><code>Printf.printf "x = %d. Bye %s\n" !x "John"</code></p>
Expand Down
3 changes: 1 addition & 2 deletions ocaml-lessons/lesson2/step4/step.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ <h3>For loops</h3>
!xl
</code></pre><br/>

<p>Here, for each value between 1 and 10, we have added it in this
order at the head of the reference.</p>
<p>Here, we have added each value between 1 and 10 at the head of the reference.</p>

<p>Of course, if we want them in the correct order, we need to reverse
the list:</p>
Expand Down
4 changes: 2 additions & 2 deletions ocaml-lessons/lesson2/step6/step.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h3>If then else</h3>
<h3>If, then, else</h3>

<p>Now that we know how to test conditions, we can use them to choose
between computations. Let's define two values : </p>
between computations. Let's define two values:</p>

<p><code>let a = 1 and b = 2</code></p><br/>

Expand Down
2 changes: 1 addition & 1 deletion ocaml-lessons/lesson3/step1/step.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h3>Defining a one-argument function</h3>
<h3>Defining functions with a single argument</h3>

<p>In OCaml defining a function with one argument, will look like this:</p>
<p><code>let incr n = n + 1</code></p>
Expand Down
6 changes: 3 additions & 3 deletions ocaml-lessons/lesson3/step2/step.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h3>Defining a multiple-arguments function</h3>
<h3>Defining functions with multiple arguments</h3>

<p>In C or Java, a function <code>plus</code>, will look like:
<p>int plus (int x, int y) { return x + y; }</p>
Expand All @@ -8,10 +8,10 @@ <h3>Defining a multiple-arguments function</h3>
<p>plus (1, 2);</p>

<br />
<p>In OCaml, the same function <code>plus</code> will be define like follow:</p>
<p>In OCaml, the same function <code>plus</code> will be defined like this:</p>
<p><code>let plus x y = x + y</code></p>

<br />
<p>To call this function, nothing is simpler:</p>
<p><code>plus 1 2</code></p>
<p>Note that there is no need to bracket or comma between function's parameters.</p>
<p>Note that there is no need for brackets, or a comma between the function's parameters.</p>
6 changes: 3 additions & 3 deletions ocaml-lessons/lesson3/step4/step.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h3>Partial application</h3>

<p>It is possible to apply a number of parameters less than what is
<p>It is possible to apply less parameters than what is
required by a function. The result would be a partial application of a
function.</p>

Expand All @@ -21,8 +21,8 @@ <h3>Partial application</h3>
<p><code>incr 42</code></p>

<br />
<p>Similarly, we can define a function which double each integer
passed as argument of the function:</p>
<p>Similarly, we can define a function which will double each integer
passed as an argument to it:</p>
<p><code>let mul x y = x * y </code><p>
<p><code>let double = mul 2</code><p>
<p><code>double 8</code><p>
4 changes: 2 additions & 2 deletions ocaml-lessons/lesson3/step5/step.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ <h3>Anonymous functions</h3>
<p><code>(fun x -> x + 1) 42</code></p>

<br />
<p>We can bound an anonymous function to an identifier. That's way, we
have severals ways to define functions:</p>
<p>We can also bound anonymous functions to identifiers (variable names). Now we
have several ways to define functions:</p>
<p><code>let incr = fun x -> x + 1</code></p>
<p><code>incr 42</code></p>
2 changes: 1 addition & 1 deletion ocaml-lessons/lesson4/step2/step.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h3>Pattern-matching on chars</h3>
| _ -> failwith "Not a valid letter"
</code></pre>

It is possible to give a name the value which is matched using the
It is possible to assign a variable name to the value which is matched using the
keyword <em>as</em>:

<pre><code>let capitalize = function
Expand Down
6 changes: 3 additions & 3 deletions ocaml-lessons/lesson4/step4/step.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ <h3>Pattern-matching on lists</h3>

<p>
However, the real power of pattern-matching appears when we start
using more structured values, when we start needing giving a name to
matched patterns. For instance, a list is either the empty
using more structured values, and when the need appears for assigning variable names to
matched patterns. For instance, a list is either an empty
list <em>[]</em> or a head and a tail, denoted by the
pattern <em>h::t</em> where <em>h</em> and <em>t</em> are fresh
variables bound to the matched patterns:

<!-- This head and tail part is not clear at all. Can somebody explain this part better? -->
<pre><code>let head = function
| [] -> failwith "empty list"
| h::t -> h
Expand Down
4 changes: 2 additions & 2 deletions ocaml-lessons/lesson4/step5/step.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<h3>Pattern-matching on arrays</h3>

<p>You can also pattern match on arrays:
<p>You can also use pattern-matching on arrays:

<pre><code>let has_size_two = function
| [| _; _ |] -> true
| _ -> false
</code></pre>

And you can mix all the kind of values:
And you can mix all kinds of values:

<pre><code>let f = function
| [] -> failwith "empty list"
Expand Down
6 changes: 3 additions & 3 deletions ocaml-lessons/lesson5/step1/step.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ <h3>Sequence of expressions</h3>
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.
<p>To begin with, you should know that a proper command must normally end with
<em>';;'</em> to be processed by the top-level interpreter. This tutorial automatically adds
the double semicolon as soon as you hit enter but the normal top-level interpreter 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>

Expand Down
4 changes: 2 additions & 2 deletions ocaml-lessons/lesson5/step3/step.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ <h3>The <em>let</em> keyword</h3>
<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:<br />
is associated with 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 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 />
Expand Down
6 changes: 3 additions & 3 deletions ocaml-lessons/lesson5/step5/step.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ <h3>Parentheses</h3>
OCaml syntax is surprisingly easy: you can use pervasively either parentheses
or <em>begin</em>/<em>end</em> keywords.</p>
<br />
<p>Example grouping expressions in an <em>if</em> form:</p>
<p>Example of grouping expressions in an <em>if</em> form:</p>
<pre><code>if 1+2 = 3 then (
print_string "did you knew that?\n" ;
print_string "amazing!\n"
Expand All @@ -16,8 +16,8 @@ <h3>Parentheses</h3>
<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
<p>Also, as function application takes precedence over infix operators, you will
frequently uses parentheses to make the expected evaluation order more explicit, as
in: <code>square (1 + 1)</code> since <code>square 1+1</code> would yield
<em>2</em>.

Expand Down