Skip to content

Commit

Permalink
easier examples in foldl/foldr docstrings (#24911)
Browse files Browse the repository at this point in the history
  • Loading branch information
jw3126 authored and fredrikekre committed Dec 7, 2017
1 parent e2e6fd2 commit 54b8b5f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions base/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ Like [`reduce`](@ref), but with guaranteed left associativity. `v0` will be used
exactly once.
```jldoctest
julia> foldl(-, 1, 2:5)
-13
julia> foldl(=>, 0, 1:4)
(((0=>1)=>2)=>3) => 4
```
"""
foldl(op, v0, itr) = mapfoldl(identity, op, v0, itr)
Expand All @@ -88,8 +88,8 @@ Like `foldl(op, v0, itr)`, but using the first element of `itr` as `v0`. In gene
cannot be used with empty collections (see [`reduce(op, itr)`](@ref)).
```jldoctest
julia> foldl(-, 2:5)
-10
julia> foldl(=>, 1:4)
((1=>2)=>3) => 4
```
"""
foldl(op, itr) = mapfoldl(identity, op, itr)
Expand Down Expand Up @@ -143,8 +143,8 @@ Like [`reduce`](@ref), but with guaranteed right associativity. `v0` will be use
exactly once.
```jldoctest
julia> foldr(-, 1, 2:5)
-1
julia> foldr(=>, 0, 1:4)
1 => (2=>(3=>(4=>0)))
```
"""
foldr(op, v0, itr) = mapfoldr(identity, op, v0, itr)
Expand All @@ -156,8 +156,8 @@ Like `foldr(op, v0, itr)`, but using the last element of `itr` as `v0`. In gener
cannot be used with empty collections (see [`reduce(op, itr)`](@ref)).
```jldoctest
julia> foldr(-, 2:5)
-2
julia> foldr(=>, 1:4)
1 => (2=>(3=>4))
```
"""
foldr(op, itr) = mapfoldr(identity, op, itr)
Expand Down

0 comments on commit 54b8b5f

Please sign in to comment.