Skip to content

Commit

Permalink
Docs formatting (#50049)
Browse files Browse the repository at this point in the history
  • Loading branch information
navidcy authored Aug 12, 2023
1 parent 0eb13d7 commit 15b590b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 48 deletions.
78 changes: 39 additions & 39 deletions doc/src/manual/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ functions are not pure mathematical functions, because they can alter and be aff
by the global state of the program. The basic syntax for defining functions in Julia is:

```jldoctest
julia> function f(x,y)
julia> function f(x, y)
x + y
end
f (generic function with 1 method)
Expand All @@ -18,7 +18,7 @@ There is a second, more terse syntax for defining a function in Julia. The tradi
declaration syntax demonstrated above is equivalent to the following compact "assignment form":

```jldoctest fofxy
julia> f(x,y) = x + y
julia> f(x, y) = x + y
f (generic function with 1 method)
```

Expand All @@ -30,7 +30,7 @@ both typing and visual noise.
A function is called using the traditional parenthesis syntax:

```jldoctest fofxy
julia> f(2,3)
julia> f(2, 3)
5
```

Expand All @@ -40,14 +40,14 @@ like any other value:
```jldoctest fofxy
julia> g = f;
julia> g(2,3)
julia> g(2, 3)
5
```

As with variables, Unicode can also be used for function names:

```jldoctest
julia> ∑(x,y) = x + y
julia> ∑(x, y) = x + y
∑ (generic function with 1 method)
julia> ∑(2, 3)
Expand Down Expand Up @@ -77,7 +77,7 @@ by the caller for this argument. On the other hand, the assignment `y = 7 + y`
`y` to refer to a new value `7 + y`, rather than mutating the *original* object referred to by `y`,
and hence does *not* change the corresponding argument passed by the caller. This can be seen if we call `f(x, y)`:
```julia-repl
julia> a = [4,5,6]
julia> a = [4, 5, 6]
3-element Vector{Int64}:
4
5
Expand Down Expand Up @@ -130,7 +130,7 @@ the `return` keyword causes a function to return immediately, providing
an expression whose value is returned:

```julia
function g(x,y)
function g(x, y)
return x * y
x + y
end
Expand All @@ -140,19 +140,19 @@ Since function definitions can be entered into interactive sessions, it is easy
definitions:

```jldoctest
julia> f(x,y) = x + y
julia> f(x, y) = x + y
f (generic function with 1 method)
julia> function g(x,y)
julia> function g(x, y)
return x * y
x + y
end
g (generic function with 1 method)
julia> f(2,3)
julia> f(2, 3)
5
julia> g(2,3)
julia> g(2, 3)
6
```

Expand All @@ -163,18 +163,18 @@ is of real use. Here, for example, is a function that computes the hypotenuse le
triangle with sides of length `x` and `y`, avoiding overflow:

```jldoctest
julia> function hypot(x,y)
julia> function hypot(x, y)
x = abs(x)
y = abs(y)
if x > y
r = y/x
return x*sqrt(1+r*r)
return x*sqrt(1 + r*r)
end
if y == 0
return zero(x)
end
r = x/y
return y*sqrt(1+r*r)
return y*sqrt(1 + r*r)
end
hypot (generic function with 1 method)
Expand Down Expand Up @@ -243,7 +243,7 @@ as you would any other function:
julia> 1 + 2 + 3
6
julia> +(1,2,3)
julia> +(1, 2, 3)
6
```

Expand All @@ -254,7 +254,7 @@ operators such as [`+`](@ref) and [`*`](@ref) just like you would with other fun
```jldoctest
julia> f = +;
julia> f(1,2,3)
julia> f(1, 2, 3)
6
```

Expand Down Expand Up @@ -402,7 +402,7 @@ left side of an assignment: the value on the right side is _destructured_ by ite
over and assigning to each variable in turn:

```jldoctest
julia> (a,b,c) = 1:3
julia> (a, b, c) = 1:3
1:3
julia> b
Expand All @@ -417,7 +417,7 @@ This can be used to return multiple values from functions by returning a tuple o
other iterable value. For example, the following function returns two values:

```jldoctest foofunc
julia> function foo(a,b)
julia> function foo(a, b)
a+b, a*b
end
foo (generic function with 1 method)
Expand All @@ -427,14 +427,14 @@ If you call it in an interactive session without assigning the return value anyw
see the tuple returned:

```jldoctest foofunc
julia> foo(2,3)
julia> foo(2, 3)
(5, 6)
```

Destructuring assignment extracts each value into a variable:

```jldoctest foofunc
julia> x, y = foo(2,3)
julia> x, y = foo(2, 3)
(5, 6)
julia> x
Expand Down Expand Up @@ -473,7 +473,7 @@ Other valid left-hand side expressions can be used as elements of the assignment
```jldoctest
julia> X = zeros(3);
julia> X[1], (a,b) = (1, (2, 3))
julia> X[1], (a, b) = (1, (2, 3))
(1, (2, 3))
julia> X
Expand Down Expand Up @@ -625,7 +625,7 @@ julia> foo(A(3, 4))
For anonymous functions, destructuring a single argument requires an extra comma:

```
julia> map(((x,y),) -> x + y, [(1,2), (3,4)])
julia> map(((x, y),) -> x + y, [(1, 2), (3, 4)])
2-element Array{Int64,1}:
3
7
Expand All @@ -638,7 +638,7 @@ Such functions are traditionally known as "varargs" functions, which is short fo
of arguments". You can define a varargs function by following the last positional argument with an ellipsis:

```jldoctest barfunc
julia> bar(a,b,x...) = (a,b,x)
julia> bar(a, b, x...) = (a, b, x)
bar (generic function with 1 method)
```

Expand All @@ -647,16 +647,16 @@ The variables `a` and `b` are bound to the first two argument values as usual, a
two arguments:

```jldoctest barfunc
julia> bar(1,2)
julia> bar(1, 2)
(1, 2, ())
julia> bar(1,2,3)
julia> bar(1, 2, 3)
(1, 2, (3,))
julia> bar(1, 2, 3, 4)
(1, 2, (3, 4))
julia> bar(1,2,3,4,5,6)
julia> bar(1, 2, 3, 4, 5, 6)
(1, 2, (3, 4, 5, 6))
```

Expand All @@ -673,7 +673,7 @@ call instead:
julia> x = (3, 4)
(3, 4)
julia> bar(1,2,x...)
julia> bar(1, 2, x...)
(1, 2, (3, 4))
```

Expand All @@ -684,7 +684,7 @@ of arguments go. This need not be the case, however:
julia> x = (2, 3, 4)
(2, 3, 4)
julia> bar(1,x...)
julia> bar(1, x...)
(1, 2, (3, 4))
julia> x = (1, 2, 3, 4)
Expand All @@ -697,15 +697,15 @@ julia> bar(x...)
Furthermore, the iterable object splatted into a function call need not be a tuple:

```jldoctest barfunc
julia> x = [3,4]
julia> x = [3, 4]
2-element Vector{Int64}:
3
4
julia> bar(1,2,x...)
julia> bar(1, 2, x...)
(1, 2, (3, 4))
julia> x = [1,2,3,4]
julia> x = [1, 2, 3, 4]
4-element Vector{Int64}:
1
2
Expand All @@ -720,17 +720,17 @@ Also, the function that arguments are splatted into need not be a varargs functi
often is):

```jldoctest
julia> baz(a,b) = a + b;
julia> baz(a, b) = a + b;
julia> args = [1,2]
julia> args = [1, 2]
2-element Vector{Int64}:
1
2
julia> baz(args...)
3
julia> args = [1,2,3]
julia> args = [1, 2, 3]
3-element Vector{Int64}:
1
2
Expand Down Expand Up @@ -831,7 +831,7 @@ prior keyword arguments.
The types of keyword arguments can be made explicit as follows:

```julia
function f(;x::Int=1)
function f(; x::Int=1)
###
end
```
Expand Down Expand Up @@ -1077,13 +1077,13 @@ in advance by the library writer.

More generally, `f.(args...)` is actually equivalent to `broadcast(f, args...)`, which allows
you to operate on multiple arrays (even of different shapes), or a mix of arrays and scalars (see
[Broadcasting](@ref)). For example, if you have `f(x,y) = 3x + 4y`, then `f.(pi,A)` will return
a new array consisting of `f(pi,a)` for each `a` in `A`, and `f.(vector1,vector2)` will return
a new vector consisting of `f(vector1[i],vector2[i])` for each index `i` (throwing an exception
[Broadcasting](@ref)). For example, if you have `f(x, y) = 3x + 4y`, then `f.(pi, A)` will return
a new array consisting of `f(pi,a)` for each `a` in `A`, and `f.(vector1, vector2)` will return
a new vector consisting of `f(vector1[i], vector2[i])` for each index `i` (throwing an exception
if the vectors have different length).

```jldoctest
julia> f(x,y) = 3x + 4y;
julia> f(x, y) = 3x + 4y;
julia> A = [1.0, 2.0, 3.0];
Expand Down
18 changes: 9 additions & 9 deletions doc/src/manual/mathematical-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ are supported on all primitive numeric types:
| `x ^ y` | power | raises `x` to the `y`th power |
| `x % y` | remainder | equivalent to `rem(x, y)` |

A numeric literal placed directly before an identifier or parentheses, e.g. `2x` or `2(x+y)`, is treated as a multiplication, except with higher precedence than other binary operations. See [Numeric Literal Coefficients](@ref man-numeric-literal-coefficients) for details.
A numeric literal placed directly before an identifier or parentheses, e.g. `2x` or `2(x + y)`, is treated as a multiplication, except with higher precedence than other binary operations. See [Numeric Literal Coefficients](@ref man-numeric-literal-coefficients) for details.

Julia's promotion system makes arithmetic operations on mixtures of argument types "just work"
naturally and automatically. See [Conversion and Promotion](@ref conversion-and-promotion) for details of the promotion
Expand Down Expand Up @@ -204,9 +204,9 @@ as `a .= a .+ b`, where `.=` is a fused *in-place* assignment operation
(see the [dot syntax documentation](@ref man-vectorized)).

Note the dot syntax is also applicable to user-defined operators.
For example, if you define `⊗(A,B) = kron(A,B)` to give a convenient
For example, if you define `⊗(A, B) = kron(A, B)` to give a convenient
infix syntax `A ⊗ B` for Kronecker products ([`kron`](@ref)), then
`[A,B] .⊗ [C,D]` will compute `[A⊗C, B⊗D]` with no additional coding.
`[A, B] .⊗ [C, D]` will compute `[A⊗C, B⊗D]` with no additional coding.

Combining dot operators with numeric literals can be ambiguous.
For example, it is not clear whether `1.+x` means `1. + x` or `1 .+ x`.
Expand Down Expand Up @@ -457,7 +457,7 @@ Juxtaposition parses like a unary operator, which has the same natural asymmetry
Julia supports three forms of numerical conversion, which differ in their handling of inexact
conversions.

* The notation `T(x)` or `convert(T,x)` converts `x` to a value of type `T`.
* The notation `T(x)` or `convert(T, x)` converts `x` to a value of type `T`.

* If `T` is a floating-point type, the result is the nearest representable value, which could be
positive or negative infinity.
Expand Down Expand Up @@ -534,7 +534,7 @@ See [Conversion and Promotion](@ref conversion-and-promotion) for how to define
| [`mod1(x, y)`](@ref) | `mod` with offset 1; returns `r∈(0, y]` for `y>0` or `r∈[y, 0)` for `y<0`, where `mod(r, y) == mod(x, y)` |
| [`mod2pi(x)`](@ref) | modulus with respect to 2pi; `0 <= mod2pi(x) < 2pi` |
| [`divrem(x, y)`](@ref) | returns `(div(x, y),rem(x, y))` |
| [`fldmod(x, y)`](@ref) | returns `(fld(x, y),mod(x, y ))` |
| [`fldmod(x, y)`](@ref) | returns `(fld(x, y), mod(x, y))` |
| [`gcd(x, y...)`](@ref) | greatest positive common divisor of `x`, `y`,... |
| [`lcm(x, y...)`](@ref) | least positive common multiple of `x`, `y`,... |

Expand All @@ -557,13 +557,13 @@ See [Conversion and Promotion](@ref conversion-and-promotion) for how to define
| [`cbrt(x)`](@ref), `∛x` | cube root of `x` |
| [`hypot(x, y)`](@ref) | hypotenuse of right-angled triangle with other sides of length `x` and `y` |
| [`exp(x)`](@ref) | natural exponential function at `x` |
| [`expm1(x)`](@ref) | accurate `exp(x)-1` for `x` near zero |
| [`ldexp(x, n)`](@ref) | `x*2^n` computed efficiently for integer values of `n` |
| [`expm1(x)`](@ref) | accurate `exp(x) - 1` for `x` near zero |
| [`ldexp(x, n)`](@ref) | `x * 2^n` computed efficiently for integer values of `n` |
| [`log(x)`](@ref) | natural logarithm of `x` |
| [`log(b, x)`](@ref) | base `b` logarithm of `x` |
| [`log2(x)`](@ref) | base 2 logarithm of `x` |
| [`log10(x)`](@ref) | base 10 logarithm of `x` |
| [`log1p(x)`](@ref) | accurate `log(1+x)` for `x` near zero |
| [`log1p(x)`](@ref) | accurate `log(1 + x)` for `x` near zero |
| [`exponent(x)`](@ref) | binary exponent of `x` |
| [`significand(x)`](@ref) | binary significand (a.k.a. mantissa) of a floating-point number `x` |

Expand All @@ -587,7 +587,7 @@ These are all single-argument functions, with [`atan`](@ref) also accepting two
corresponding to a traditional [`atan2`](https://en.wikipedia.org/wiki/Atan2) function.

Additionally, [`sinpi(x)`](@ref) and [`cospi(x)`](@ref) are provided for more accurate computations
of [`sin(pi*x)`](@ref) and [`cos(pi*x)`](@ref) respectively.
of [`sin(pi * x)`](@ref) and [`cos(pi * x)`](@ref) respectively.

In order to compute trigonometric functions with degrees instead of radians, suffix the function
with `d`. For example, [`sind(x)`](@ref) computes the sine of `x` where `x` is specified in degrees.
Expand Down

3 comments on commit 15b590b

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily package evaluation, I will reply here when finished:

@nanosoldier runtests(isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily package evaluation, I will reply here when finished:

@nanosoldier runtests(isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package evaluation job you requested has completed - possible new issues were detected.
The full report is available.

Please sign in to comment.