@@ -7,17 +7,17 @@ Separate several parameters with commas:
77
88## Parameters and Return Types
99
10- Function parameters come with their type, which is given after a colon
10+ Function parameters come with their type, which is given after a colon:
1111
1212 def power(x: Double, y: Int): Double = ...
1313
1414If a return type is given, it follows the parameter list.
1515
1616## Val vs Def
1717
18- The right hand side of a ` def ` definition is evaluated on each use.
18+ The right- hand side of a ` def ` definition is evaluated on each use.
1919
20- The right hand side of a ` val ` definition is evaluated at the point of the definition
20+ The right- hand side of a ` val ` definition is evaluated at the point of the definition
2121itself. Afterwards, the name refers to the value.
2222
2323 val x = 2
@@ -27,11 +27,11 @@ For instance, `y` above refers to `4`, not `square(2)`.
2727
2828## Evaluation of Function Applications
2929
30- Applications of parametrized functions are evaluated in a similar way as
30+ Applications of parametrized functions are evaluated in a way similar to
3131operators:
3232
3333 1 . Evaluate all function arguments, from left to right.
34- 2 . Replace the function application by the function's right-hand side, and, at the same time
34+ 2 . Replace the function application by the function's right-hand side and, at the same time
3535 3 . Replace the formal parameters of the function by the actual arguments.
3636
3737## Example
@@ -52,7 +52,7 @@ This scheme of expression evaluation is called the *substitution model*.
5252The idea underlying this model is that all evaluation does is * reduce
5353an expression to a value* .
5454
55- It can be applied to all expressions, as long as they have no side effects.
55+ It can be applied to all expressions as long as they have no side effects.
5656
5757The substitution model is formalized in the λ-calculus, which gives
5858a foundation for functional programming.
@@ -69,8 +69,8 @@ No. Here is a counter-example:
6969
7070## Value Definitions and Termination
7171
72- The difference between ` val ` and ` def ` becomes apparent when the right
73- hand side does not terminate. Given
72+ The difference between ` val ` and ` def ` becomes apparent when the right-hand
73+ side does not terminate. Given
7474
7575 def loop: Int = loop
7676
@@ -124,5 +124,5 @@ Scala normally uses call-by-value.
124124## Exercise
125125
126126Complete the following definition of the ` triangleArea ` function,
127- which takes a triangle base and height as parameters and returns
127+ which takes the base and height of a triangle as parameters and returns
128128its area.
0 commit comments