# Is previous function apply remove from base?

**URL:** <https://discourse.julialang.org/t/is-previous-function-apply-remove-from-base/90367>\
**Category:** General Usage\
**Tags:** question\
**Created:** [November 16, 2022, 7:20pm UTC](https://discourse.julialang.org/t/is-previous-function-apply-remove-from-base/90367 "2022-11-16T19:20:05Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![somranger](https://avatars.discourse-cdn.com/v4/letter/s/3ab097/32.png) [@somranger](https://discourse.julialang.org/u/somranger)\
**Post date:** [November 16, 2022, 7:20pm UTC](https://discourse.julialang.org/t/is-previous-function-apply-remove-from-base/90367/1 "2022-11-16T19:20:05Z")

</div>

In this link, [https://stackoverflow.com/a/22873866/20438781](https://stackoverflow.com/a/22873866/20438781)  
it seems that there was an `apply` function transfer a tuple to a function. However, it disappears in current version, and [Varargs Functions](https://docs.julialang.org/en/v1/manual/functions/#Varargs-Functions) still exists. Certainly Varargs Functions could substitute part of abilities of `apply`, but I don’t consider there are the same thing.  
My questions are, what is the complete function version of `f(...)`? Is there any function with the same usage as `apply`? And how to transfer a vector to a function without unpacking? Is it necessary to transform vector to tuple and be apply by a function?

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [November 16, 2022, 7:27pm UTC](https://discourse.julialang.org/t/is-previous-function-apply-remove-from-base/90367/2 "2022-11-16T19:27:32Z")

</div>

`apply` was deprecated in Julia 0.4 in favor of the splat operator.

```julia
 $ ~/julia0.4/bin/julia
               _
   _ _ _(_)_ | A fresh approach to technical computing
  (_) | (_) (_) | Documentation: http://docs.julialang.org
   _ _ _| |_ __ _ | Type "?help" for help.
  | | | | | | |/ _` | |
  | | |_| | | | (_| | | Version 0.4.7 (2016-09-18 16:17 UTC)
 _/ |\ __'_|_|_|\__'_| | Official http://julialang.org/ release
|__/ | x86_64-pc-linux-gnu

julia> apply(+, (1, 2, 3))
WARNING: apply(f, x) is deprecated, use `f(x...)` instead

```

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [November 16, 2022, 7:41pm UTC](https://discourse.julialang.org/t/is-previous-function-apply-remove-from-base/90367/3 "2022-11-16T19:41:34Z")

</div>

> [@somranger](#):
>
> My questions are, what is the complete function version of `f(...)`? Is there any function with the same usage as `apply`? And how to transfer a vector to a function without unpacking? Is it necessary to transform vector to tuple and be apply by a function?

You could trivially write one by writing

```julia
apply(f, args) = f(args...)

```

---

<div class="post-metadata">

**Author:** ![somranger](https://avatars.discourse-cdn.com/v4/letter/s/3ab097/32.png) [@somranger](https://discourse.julialang.org/u/somranger)\
**Post date:** [November 17, 2022, 2:58pm UTC](https://discourse.julialang.org/t/is-previous-function-apply-remove-from-base/90367/4 "2022-11-17T14:58:14Z")

</div>

So there isn’t `apply` anymore, just splat operator without function form. And there are also many operators without function form.

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [November 17, 2022, 3:01pm UTC](https://discourse.julialang.org/t/is-previous-function-apply-remove-from-base/90367/5 "2022-11-17T15:01:21Z")

</div>

Most operators in Julia are just functions. The only ones that aren’t are the ones that manipulate syntax or have some kind of control flow effect, meaning that they could not be functions.

---

<div class="post-metadata">

**Author:** ![Per](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/per/32/10387_2.png) [@Per](https://discourse.julialang.org/u/Per)\
**Post date:** [November 17, 2022, 3:35pm UTC](https://discourse.julialang.org/t/is-previous-function-apply-remove-from-base/90367/6 "2022-11-17T15:35:06Z")

</div>

> [@somranger](#):
>
> Is it necessary to transform vector to tuple and be apply by a function?

Anything that can be iterated over can be splatted. This includes vectors. However, in many cases it is more efficient to use a function that expects a vector instead of splatting. For example `sum(x)` might be slightly faster than `+(x...)` when `x` is a vector.

What is it that you want to use this for?

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [November 17, 2022, 6:40pm UTC](https://discourse.julialang.org/t/is-previous-function-apply-remove-from-base/90367/7 "2022-11-17T18:40:37Z")

</div>

> [@somranger](#):
>
> So there isn’t `apply` anymore, just splat operator without function form.

Can you perhaps show an example where you think `apply` is more convenient than splat? Personally, I find splat far nicer, so I’m curious.

---

<div class="post-metadata">

**Author:** ![somranger](https://avatars.discourse-cdn.com/v4/letter/s/3ab097/32.png) [@somranger](https://discourse.julialang.org/u/somranger)\
**Post date:** [November 17, 2022, 7:27pm UTC](https://discourse.julialang.org/t/is-previous-function-apply-remove-from-base/90367/8 "2022-11-17T19:27:00Z")

</div>

You are definitely correct and I also agree splat is convenient. Just I hope every operator with a specific function form.

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [November 17, 2022, 7:39pm UTC](https://discourse.julialang.org/t/is-previous-function-apply-remove-from-base/90367/9 "2022-11-17T19:39:25Z")

</div>

Oh, if I had known that was your actual concern I would have pointed out that there’s a function in `Base.splat` (soon to be exported as `Splat` in v1.9) that does this as a higher order function.

```julia
julia> Base.splat(+)((1,2,3,4))
10

```

That is, the old `apply` can be written as

```julia
apply(f, args) = Base.splat(f)(args)

```

To ease this, I’ve added a PR to Compat.jl to export `Splat`: [add `Splat` by MasonProtter · Pull Request #785 · JuliaLang/Compat.jl · GitHub](https://github.com/JuliaLang/Compat.jl/pull/785)
