Skip to content

Commit

Permalink
Extend documentation for Base.splat
Browse files Browse the repository at this point in the history
  • Loading branch information
Seelengrab committed Oct 20, 2021
1 parent bdb04c3 commit 56def41
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions base/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1257,14 +1257,14 @@ string(s::Splat) = string("splat(", s.f, ')')
"""
splat(f)
Defined as
Equivalent to
```julia
splat(f) = args->f(args...)
my_splat(f) = args->f(args...)
```
i.e. given a function returns a new function that takes one argument and splats
its argument into the original function. This is useful as an adaptor to pass
a multi-argument function in a context that expects a single argument, but
passes a tuple as that single argument.
passes a tuple as that single argument. Additionally has pretty printing.
# Example usage:
```jldoctest
Expand All @@ -1273,6 +1273,12 @@ julia> map(Base.splat(+), zip(1:3,4:6))
5
7
9
julia> my_add = Base.splat(+)
splat(+)
julia> my_add((1,2,3))
6
```
"""
splat(f) = Splat(f)
Expand Down

0 comments on commit 56def41

Please sign in to comment.