Skip to content

Commit bef66e1

Browse files
Fix typos in Programming Examples
Co-authored-by: Maria Scott <maria-12648430@hnc-agency.org>
1 parent 5c44cb6 commit bef66e1

4 files changed

Lines changed: 27 additions & 27 deletions

File tree

system/doc/programming_examples/bit_syntax.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ This gives two binaries of size 3, with the following evaluations:
7777
- [`binary_to_list(Bin11)`](`binary_to_list/1`) evaluates to `[1, 17, 42]`.
7878
- [`binary_to_list(Bin12)`](`binary_to_list/1`) evaluates to `[97, 98, 99]`.
7979

80-
*Example 2:*Similarly, a binary can be constructed from a set of bound
80+
*Example 2:* Similarly, a binary can be constructed from a set of bound
8181
variables:
8282

8383
```erlang
@@ -86,7 +86,7 @@ Bin2 = <<A, B, C:16>>
8686
```
8787

8888
This gives a binary of size 4. Here, a _size expression_ is used for the
89-
variable `C` to specify a 16-bits segment of `Bin2`.
89+
variable `C` to specify a 16-bit segment of `Bin2`.
9090

9191
[`binary_to_list(Bin2)`](`binary_to_list/1`) evaluates to `[1, 17, 00, 42]`.
9292

@@ -135,7 +135,7 @@ variables do. Both can bind to empty binaries.
135135

136136
The match of `Dgram` fails if one of the following occurs:
137137

138-
- The first 4-bits segment of `Dgram` is not equal to 4.
138+
- The first 4-bit segment of `Dgram` is not equal to 4.
139139
- `HLen` is less than 5.
140140
- The size of `Dgram` is less than `4*HLen`.
141141

@@ -150,7 +150,7 @@ Each segment has the following general syntax:
150150

151151
`Value:Size/TypeSpecifierList`
152152

153-
The `Size` or the `TypeSpecifier`, or both, can be omitted. Thus, the following
153+
The `Size` or the `TypeSpecifierList`, or both, can be omitted. Thus, the following
154154
variants are allowed:
155155

156156
- `Value`
@@ -240,7 +240,7 @@ _Example:_
240240
```
241241

242242
The variable `Bin` must contain a whole number of bytes, because the `binary`
243-
type defaults to `unit:8`. A `badarg` exception is generated if `Bin` consist
243+
type defaults to `unit:8`. A `badarg` exception is generated if `Bin` consists
244244
of, for example, 17 bits.
245245

246246
The `Bitstring` variable can consist of any number of bits, for example, 0, 1,
@@ -264,7 +264,7 @@ As mentioned earlier, segments have the following general syntax:
264264

265265
When constructing binaries, `Value` and `Size` can be any Erlang expression.
266266
However, for syntactical reasons, both `Value` and `Size` must be enclosed in
267-
parenthesis if the expression consists of anything more than a single literal or
267+
parentheses if the expression consists of anything more than a single literal or
268268
a variable. The following gives a compiler syntax error:
269269

270270
```erlang
@@ -309,7 +309,7 @@ As mentioned earlier, segments have the following general syntax:
309309

310310
`Value:Size/TypeSpecifierList`
311311

312-
When matching `Value`, value must be either a variable or an integer, or a
312+
When matching `Value`, `Value` must be either a variable or an integer, or a
313313
floating point literal. Expressions are not allowed.
314314

315315
`Size` must be a
@@ -349,7 +349,7 @@ bar(<<Sz:8,Payload:Sz/binary-unit:8,Rest/binary>>) ->
349349
```
350350

351351
Here `Sz` is bound to the value in the first byte of the binary. `Sz` is then
352-
used at the number of bytes to match out as a binary.
352+
used as the number of bytes to match out as a binary.
353353

354354
Starting in OTP 23, the size can be a guard expression:
355355

system/doc/programming_examples/funs.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,15 @@ Using the function `foreach`, the function `broadcast` becomes:
125125
foreach(fun(Pid) -> Pid ! M end, L)
126126
```
127127

128-
`foreach` is evaluated for its side-effect and not its value. `foreach(Fun ,L)`
128+
`foreach` is evaluated for its side-effect and not its value. `foreach(Fun, L)`
129129
calls `Fun(X)` for each element `X` in `L` and the processing occurs in the
130130
order that the elements were defined in `L`. `map` does not define the order in
131131
which its elements are processed.
132132

133133
## Syntax of Funs
134134

135135
Funs are written with the following syntax (see
136-
[Fun Expressions ](`e:system:expressions.md#fun-expressions`)for full description):
136+
[Fun Expressions](`e:system:expressions.md#fun-expressions`) for full description):
137137

138138
```erlang
139139
F = fun (Arg1, Arg2, ... ArgN) ->
@@ -249,7 +249,7 @@ diagnostic:
249249
This indicates that the variable `File`, which is defined inside the fun,
250250
collides with the variable `File`, which is defined outside the fun.
251251

252-
The rules for importing variables into a fun has the consequence that certain
252+
The rules for importing variables into a fun have the consequence that certain
253253
pattern matching operations must be moved into guard expressions and cannot be
254254
written in the head of the fun. For example, you might write the following code
255255
if you intend the first clause of `F` to be evaluated when the value of its
@@ -323,7 +323,7 @@ any(Pred, []) ->
323323
A predicate is a function that returns `true` or `false`. `any` is `true` if
324324
there is a term `X` in the list such that `P(X)` is `true`.
325325

326-
A predicate `Big(X)` is defined, which is `true` if its argument is greater that
326+
A predicate `Big(X)` is defined, which is `true` if its argument is greater than
327327
10:
328328

329329
```erlang
@@ -489,7 +489,7 @@ diff(L1, L2) ->
489489

490490
This gives the list of all elements in L1 that are not contained in L2.
491491

492-
The AND intersection of the list `L1` and `L2` is also easily defined:
492+
The AND intersection of the lists `L1` and `L2` is also easily defined:
493493

494494
```erlang
495495
intersection(L1,L2) -> filter(fun(X) -> member(X,L1) end, L2).
@@ -537,7 +537,7 @@ dropwhile(Pred, []) ->
537537
### splitwith
538538

539539
`lists:splitwith/2` splits the list `L` into the two sublists `{L1, L2}`, where
540-
`L = takewhile(P, L)` and `L2 = dropwhile(P, L)`:
540+
`L1 = takewhile(P, L)` and `L2 = dropwhile(P, L)`:
541541

542542
```erlang
543543
splitwith(Pred, L) ->
@@ -561,7 +561,7 @@ splitwith(Pred, [], L) ->
561561

562562
So far, only functions that take funs as arguments have been described. More
563563
powerful functions, that themselves return funs, can also be written. The
564-
following examples illustrate these type of functions.
564+
following examples illustrate these types of functions.
565565

566566
### Simple Higher Order Functions
567567

@@ -619,7 +619,7 @@ Parser(Toks) -> {ok, Tree, Toks1} | fail
619619
`{ok, Tree, Toks1}`.
620620

621621
- `Tree` is a parse tree.
622-
- `Toks1` is a tail of `Tree` that contains symbols encountered after the
622+
- `Toks1` is a tail of `Toks` that contains symbols encountered after the
623623
structure that was correctly parsed.
624624

625625
An unsuccessful parse returns `fail`.

system/doc/programming_examples/list_comprehensions.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ removed:
138138
Pythagorean triplets are sets of integers `{A,B,C}` such that
139139
`A**2 + B**2 = C**2`.
140140

141-
The function `pyth(N)` generates a list of all integers `{A,B,C}` such that
141+
The function `pyth(N)` generates a list of all tuples `{A,B,C}` such that
142142
`A**2 + B**2 = C**2` and where the sum of the sides is equal to, or less than,
143143
`N`:
144144

@@ -208,7 +208,7 @@ The scope rules for variables that occur in list comprehensions are as follows:
208208
- Any variables that are defined before the list comprehension, and that are
209209
used in filters, have the values they had before the list comprehension.
210210
- Variables cannot be exported from a list comprehension.
211-
- Within a zip generator, binding of all variables happen at the same time.
211+
- Within a zip generator, binding of all variables happens at the same time.
212212

213213
As an example of these rules, suppose you want to write the function `select`,
214214
which selects certain elements from a list of tuples. Suppose you write
@@ -256,7 +256,7 @@ same name bound in a previous generator pattern. For example:
256256
[{a,a},{b,b},{c,c},{a,a},{b,b},{c,c},{a,a},{b,b},{c,c}]
257257
```
258258

259-
A consequence of the rules for importing variables into a list comprehensions is
259+
A consequence of the rules for importing variables into a list comprehension is
260260
that certain pattern matching operations must be moved into the filters and
261261
cannot be written directly in the generators.
262262

@@ -305,7 +305,7 @@ linter. It extracts arities from all defined functions. All elements in the
305305
list `DefinedFuns` are two-tuples, containing name and arity for functions.
306306
If any of them differs from this pattern, it means that something has added
307307
an invalid item into the list of defined functions. It is better for the linter
308-
to crash in the comprehension than skipping the invalid item and continue
308+
to crash in the comprehension than to skip the invalid item and continue
309309
running. Using a strict generator here is correct, because the linter should
310310
not hide the presence of an internal inconsistency.
311311

@@ -320,9 +320,9 @@ from the comprehension result.
320320

321321
For example, the following comprehension is from a compiler module that
322322
transforms normal Erlang code to Core Erlang. It finds all defined functions
323-
from an abstract form, and output them in two-tuples, each containing name and
323+
from an abstract form, and outputs them in two-tuples, each containing name and
324324
arity of a function. Not all forms are function declarations. All the forms
325-
that are not function declarations should be ignored by this comprehensions.
325+
that are not function declarations should be ignored by this comprehension.
326326
Using a relaxed generator here is correct, because the programmer intends to
327327
exclude all elements with other patterns.
328328

system/doc/programming_examples/prog_ex_records.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ following example, a record instead of a tuple is used to store the data:
5757
```
5858

5959
This enables references to the fields of the record by name. For example, if `P`
60-
is a variable whose value is a `person` record, the following code access the
61-
name and address fields of the records:
60+
is a variable whose value is a `person` record, the following code accesses the
61+
name and address fields of the record:
6262

6363
```erlang
6464
Name = P#person.name,
@@ -74,9 +74,9 @@ Internally, records are represented using tagged tuples:
7474

7575
## Defining a Record
7676

77-
This following definition of a `person` is used in several examples in this
77+
The following definition of a `person` is used in several examples in this
7878
section. Three fields are included, `name`, `phone`, and `address`. The default
79-
values for `name` and `phone` is "" and [], respectively. The default value for
79+
values for `name` and `phone` are "" and [], respectively. The default value for
8080
`address` is the atom `undefined`, since no default value is supplied for this
8181
field:
8282

@@ -145,7 +145,7 @@ The following example shows how to update a record:
145145

146146
## Type Testing
147147

148-
The following example shows that the guard succeeds if `P` is record of type
148+
The following example shows that the guard succeeds if `P` is a record of type
149149
`person`:
150150

151151
```erlang

0 commit comments

Comments
 (0)