From 8e11620f277bb9c2f6e657de4b2acecb6308c57c Mon Sep 17 00:00:00 2001 From: nandorpersanyi Date: Sat, 5 Jan 2019 22:44:49 +0100 Subject: [PATCH] fix typos and grammar --- ocaml-lessons/lesson1/step3/step.html | 2 +- ocaml-lessons/lesson1/step6/step.html | 10 +++++----- ocaml-lessons/lesson2/step1/step.html | 14 +++++++------- ocaml-lessons/lesson2/step2/step.html | 10 +++++----- ocaml-lessons/lesson2/step3/step.html | 2 +- ocaml-lessons/lesson2/step4/step.html | 3 +-- ocaml-lessons/lesson2/step6/step.html | 4 ++-- ocaml-lessons/lesson3/step1/step.html | 2 +- ocaml-lessons/lesson3/step2/step.html | 6 +++--- ocaml-lessons/lesson3/step4/step.html | 6 +++--- ocaml-lessons/lesson3/step5/step.html | 4 ++-- ocaml-lessons/lesson4/step2/step.html | 2 +- ocaml-lessons/lesson4/step4/step.html | 6 +++--- ocaml-lessons/lesson4/step5/step.html | 4 ++-- ocaml-lessons/lesson5/step1/step.html | 6 +++--- ocaml-lessons/lesson5/step3/step.html | 4 ++-- ocaml-lessons/lesson5/step5/step.html | 6 +++--- 17 files changed, 45 insertions(+), 46 deletions(-) diff --git a/ocaml-lessons/lesson1/step3/step.html b/ocaml-lessons/lesson1/step3/step.html index 98c53b2..e7b1bfa 100644 --- a/ocaml-lessons/lesson1/step3/step.html +++ b/ocaml-lessons/lesson1/step3/step.html @@ -16,7 +16,7 @@

Operations on arrays


To get the element number i of an array, you have two -ways to do this (don't forget, the first element has number 0):

+ways to do this (don't forget, the first index of an Array is always 0):

Array.get [| 42; 51; 32 |] 2

or

diff --git a/ocaml-lessons/lesson1/step6/step.html b/ocaml-lessons/lesson1/step6/step.html index 592b808..461e619 100644 --- a/ocaml-lessons/lesson1/step6/step.html +++ b/ocaml-lessons/lesson1/step6/step.html @@ -1,15 +1,15 @@

Operations on Tuples

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

+and separated by commas. Note that you can have different types for +each element:

(42, "John", true)


-

When you have a pair (a tuple with two elements), you can use some -predefined functions like get the first element:

+

When you have a pair (a tuple with two elements), you can use +predefined functions like getting the first element:

fst (42, "John")


-

Or the second element:

+

or the second element:

snd (42, "John")

diff --git a/ocaml-lessons/lesson2/step1/step.html b/ocaml-lessons/lesson2/step1/step.html index 52cd559..89dcbfa 100644 --- a/ocaml-lessons/lesson2/step1/step.html +++ b/ocaml-lessons/lesson2/step1/step.html @@ -1,17 +1,17 @@

Variables

-

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

- +

Similarly to other languages, you can associate user defined variable names with values. To do +that, we use the let syntax which associates the result of value declaration, or some computation with a user defined variable name:

+

let a = 42

let x = 6 * 7


-

We can now check the value associated with x in the +

We can now check the value associated with a, or x in the toplevel:

+

a

x


-

And we can use the name where we would like the value:

-

let y = x + 1

+

And we can just use the variable name where we would like to access the value:

+

let y = a + x

diff --git a/ocaml-lessons/lesson2/step2/step.html b/ocaml-lessons/lesson2/step2/step.html index 7e268d0..ee1ae4d 100644 --- a/ocaml-lessons/lesson2/step2/step.html +++ b/ocaml-lessons/lesson2/step2/step.html @@ -1,15 +1,15 @@

Mutable Variables

-

In OCaml, you cannot change the value associated with a name after +

In OCaml, you cannot change the value associated with a variable after its definition. Trying to do so will trigger a compilation error:

x <- x + 1

You will better understand the error message later.


-

If you really want to modify the value associated with a name, you -must use a trick. OCaml provides a function ref that -creates a special value that can be modified later (a reference):

+

If you really want to modify the value associated with a variable, you +must use a "trick". OCaml provides the ref syntax, that +creates a special value, that can be modified later (a reference):

let x = ref 42


@@ -18,7 +18,7 @@

Mutable Variables

x := 100 / 4


-

You can also access the value contained in the reference using the +

You can access the value contained in the reference using the operator !:

let y = !x + 1

diff --git a/ocaml-lessons/lesson2/step3/step.html b/ocaml-lessons/lesson2/step3/step.html index e91954d..0ed20da 100644 --- a/ocaml-lessons/lesson2/step3/step.html +++ b/ocaml-lessons/lesson2/step3/step.html @@ -16,7 +16,7 @@

Sequences and Printing

print_newline ()

A more powerful method to print values -is Printf.printf, whose behavior is similar +is Printf.printf, which is similar to printf in C:

Printf.printf "x = %d. Bye %s\n" !x "John"

diff --git a/ocaml-lessons/lesson2/step4/step.html b/ocaml-lessons/lesson2/step4/step.html index c267094..09f5e2f 100644 --- a/ocaml-lessons/lesson2/step4/step.html +++ b/ocaml-lessons/lesson2/step4/step.html @@ -14,8 +14,7 @@

For loops

!xl
-

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

+

Here, we have added each value between 1 and 10 at the head of the reference.

Of course, if we want them in the correct order, we need to reverse the list:

diff --git a/ocaml-lessons/lesson2/step6/step.html b/ocaml-lessons/lesson2/step6/step.html index ec8fc38..c3c90cb 100644 --- a/ocaml-lessons/lesson2/step6/step.html +++ b/ocaml-lessons/lesson2/step6/step.html @@ -1,7 +1,7 @@ -

If then else

+

If, then, else

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

+between computations. Let's define two values:

let a = 1 and b = 2


diff --git a/ocaml-lessons/lesson3/step1/step.html b/ocaml-lessons/lesson3/step1/step.html index cf582b4..3ac56f3 100644 --- a/ocaml-lessons/lesson3/step1/step.html +++ b/ocaml-lessons/lesson3/step1/step.html @@ -1,4 +1,4 @@ -

Defining a one-argument function

+

Defining functions with a single argument

In OCaml defining a function with one argument, will look like this:

let incr n = n + 1

diff --git a/ocaml-lessons/lesson3/step2/step.html b/ocaml-lessons/lesson3/step2/step.html index 90a4c27..c4e581f 100644 --- a/ocaml-lessons/lesson3/step2/step.html +++ b/ocaml-lessons/lesson3/step2/step.html @@ -1,4 +1,4 @@ -

Defining a multiple-arguments function

+

Defining functions with multiple arguments

In C or Java, a function plus, will look like:

int plus (int x, int y) { return x + y; }

@@ -8,10 +8,10 @@

Defining a multiple-arguments function

plus (1, 2);


-

In OCaml, the same function plus will be define like follow:

+

In OCaml, the same function plus will be defined like this:

let plus x y = x + y


To call this function, nothing is simpler:

plus 1 2

-

Note that there is no need to bracket or comma between function's parameters.

+

Note that there is no need for brackets, or a comma between the function's parameters.

diff --git a/ocaml-lessons/lesson3/step4/step.html b/ocaml-lessons/lesson3/step4/step.html index f69649d..8caa07e 100644 --- a/ocaml-lessons/lesson3/step4/step.html +++ b/ocaml-lessons/lesson3/step4/step.html @@ -1,6 +1,6 @@

Partial application

-

It is possible to apply a number of parameters less than what is +

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

@@ -21,8 +21,8 @@

Partial application

incr 42


-

Similarly, we can define a function which double each integer -passed as argument of the function:

+

Similarly, we can define a function which will double each integer +passed as an argument to it:

let mul x y = x * y

let double = mul 2

double 8

diff --git a/ocaml-lessons/lesson3/step5/step.html b/ocaml-lessons/lesson3/step5/step.html index 1e2fd8b..0c3a7f6 100644 --- a/ocaml-lessons/lesson3/step5/step.html +++ b/ocaml-lessons/lesson3/step5/step.html @@ -5,7 +5,7 @@

Anonymous functions

(fun x -> x + 1) 42


-

We can bound an anonymous function to an identifier. That's way, we -have severals ways to define functions:

+

We can also bound anonymous functions to identifiers (variable names). Now we +have several ways to define functions:

let incr = fun x -> x + 1

incr 42

diff --git a/ocaml-lessons/lesson4/step2/step.html b/ocaml-lessons/lesson4/step2/step.html index 77f4ca8..21b6e24 100644 --- a/ocaml-lessons/lesson4/step2/step.html +++ b/ocaml-lessons/lesson4/step2/step.html @@ -9,7 +9,7 @@

Pattern-matching on chars

| _ -> failwith "Not a valid letter" -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 as:
let capitalize = function
diff --git a/ocaml-lessons/lesson4/step4/step.html b/ocaml-lessons/lesson4/step4/step.html
index 93a14c5..1ba0189 100644
--- a/ocaml-lessons/lesson4/step4/step.html
+++ b/ocaml-lessons/lesson4/step4/step.html
@@ -2,12 +2,12 @@ 

Pattern-matching on lists

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 [] or a head and a tail, denoted by the pattern h::t where h and t are fresh variables bound to the matched patterns: - +

let head = function
   | []   -> failwith "empty list"
   | h::t -> h
diff --git a/ocaml-lessons/lesson4/step5/step.html b/ocaml-lessons/lesson4/step5/step.html
index e54ef37..cac5123 100644
--- a/ocaml-lessons/lesson4/step5/step.html
+++ b/ocaml-lessons/lesson4/step5/step.html
@@ -1,13 +1,13 @@
 

Pattern-matching on arrays

-

You can also pattern match on arrays: +

You can also use pattern-matching on arrays:

let has_size_two = function
   | [| _; _ |] -> true
   | _          -> false
 
-And you can mix all the kind of values: +And you can mix all kinds of values:
let f = function
   | []                 -> failwith "empty list"
diff --git a/ocaml-lessons/lesson5/step1/step.html b/ocaml-lessons/lesson5/step1/step.html
index b406b2a..64771cd 100644
--- a/ocaml-lessons/lesson5/step1/step.html
+++ b/ocaml-lessons/lesson5/step1/step.html
@@ -5,9 +5,9 @@ 

Sequence of expressions

any deeper.


-

To begin with, you should know that a proper command must normally ends with -';;' 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. +

To begin with, you should know that a proper command must normally end with +';;' 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.

diff --git a/ocaml-lessons/lesson5/step3/step.html b/ocaml-lessons/lesson5/step3/step.html index c966030..fc4b8ba 100644 --- a/ocaml-lessons/lesson5/step3/step.html +++ b/ocaml-lessons/lesson5/step3/step.html @@ -11,10 +11,10 @@

The let keyword



The let 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:
+is associated with some value temporarily, for the evaluation of a subexpression only:
let x = 41 in x + 1
- The value of x is 41 during +The value of x is 41 during the evaluation of x + 1 only; the global binding of x to "I am now a string!" is preserved.


diff --git a/ocaml-lessons/lesson5/step5/step.html b/ocaml-lessons/lesson5/step5/step.html index 1fab8a1..9891abe 100644 --- a/ocaml-lessons/lesson5/step5/step.html +++ b/ocaml-lessons/lesson5/step5/step.html @@ -4,7 +4,7 @@

Parentheses

OCaml syntax is surprisingly easy: you can use pervasively either parentheses or begin/end keywords.


-

Example grouping expressions in an if form:

+

Example of grouping expressions in an if form:

if 1+2 = 3 then (
   print_string "did you knew that?\n" ;
   print_string "amazing!\n"
@@ -16,8 +16,8 @@ 

Parentheses

begin 1 + 2 end * 3

-

Also, as function application takes precedence over infix operators you will -frequently uses parentheses to make explicit the expected evaluation order, as +

Also, as function application takes precedence over infix operators, you will +frequently uses parentheses to make the expected evaluation order more explicit, as in: square (1 + 1) since square 1+1 would yield 2.