|
44 | 44 | plus (generic function with 1 method)
|
45 | 45 | ```
|
46 | 46 |
|
47 |
| -The example above contains the `println` function on the last line. However, if the function is called, nothing is printed into the REPL. The happened because expressions after the `return` keyword are never evaluated. |
| 47 | +The example above contains the `println` function on the last line. However, if the function is called, nothing is printed into the REPL. This is because expressions after the `return` keyword are never evaluated. |
48 | 48 |
|
49 | 49 | ```jldoctest functions
|
50 | 50 | julia> plus(4, 5)
|
@@ -75,7 +75,7 @@ julia> typeof(ps)
|
75 | 75 | NTuple{4,Int64}
|
76 | 76 | ```
|
77 | 77 |
|
78 |
| -Since the function returns a tuple, returned values can be directly unpacked into multiple variables. This can be done in the same way as unpacking [tuples](@ref Tuples). |
| 78 | +Note that the function returns `NTuple{4, Int64}` which is a compact way of representing the type for a tuple of length `N = 4` where all elements are of the same type. Since the function returns a tuple, returned values can be directly unpacked into multiple variables. This can be done in the same way as unpacking [tuples](@ref Tuples). |
79 | 79 |
|
80 | 80 | ```jldoctest functions
|
81 | 81 | julia> x1, x2, x3, x4 = powers(2)
|
@@ -105,7 +105,7 @@ To use recursion, we have to split the computation into three parts:
|
105 | 105 | - `p > 0`: the function should be called recursively with arguments `x`, `p - 1` and the result should be multiplied by `x`.
|
106 | 106 | - `p < 0`: then it is equivalent to call the power function with arguments `1/x`, `-p`.
|
107 | 107 |
|
108 |
| -These three cases can be defined in one `if` condition as follows: |
| 108 | +These three cases can be defined using the `if-elseif` as follows: |
109 | 109 |
|
110 | 110 | ```jldoctest functions_ex; output = false
|
111 | 111 | function power(x::Real, p::Integer)
|
@@ -401,7 +401,7 @@ julia> linear(2; a = 2, b = 4)
|
401 | 401 | The semicolon is not mandatory and can be omitted. Moreover, the order of keyword arguments is arbitrary. It is even possible to mix keyword arguments with positional arguments, as shown in the following example.
|
402 | 402 |
|
403 | 403 | ```jldoctest key_args
|
404 |
| -julia> linear(b = 4, 2, a = 2) # If you use this, you will burn in hell. Also, Vasek does not check my changes :D |
| 404 | +julia> linear(b = 4, 2, a = 2) # If you use this, you will burn in hell :D |
405 | 405 | 8
|
406 | 406 | ```
|
407 | 407 |
|
@@ -714,7 +714,7 @@ Those two function declarations create functions with automatically generated na
|
714 | 714 | ```@example
|
715 | 715 | using Plots
|
716 | 716 |
|
717 |
| -f(x,a) = (x+a)^2 |
| 717 | +f(x,a) = (x + a)^2 |
718 | 718 | plot(-1:0.01:1, x -> f(x,0.5))
|
719 | 719 |
|
720 | 720 | savefig("Plots.svg") # hide
|
|
0 commit comments