# \`Vector{Function}\` behaves strangely when length is one

**URL:** https://discourse.julialang.org/t/vector-function-behaves-strangely-when-length-is-one/119197
**Category:** General Usage
**Tags:** type, function
**Created:** [September 8, 2024, 7:36pm UTC](https://discourse.julialang.org/t/vector-function-behaves-strangely-when-length-is-one/119197 "2024-09-08T19:36:02Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Mikhail\_Kagalenko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikhail_kagalenko/32/13257_2.png) [@Mikhail\_Kagalenko](https://discourse.julialang.org/u/Mikhail_Kagalenko)
#### Post date: [September 8, 2024, 7:36pm UTC](https://discourse.julialang.org/t/vector-function-behaves-strangely-when-length-is-one/119197/1 "2024-09-08T19:36:02Z")

</div>

```julia
julia> f(x)=x+1
f (generic function with 1 method)

julia> isa(f, Function)
true

julia> typeof([f])
Vector{typeof(f)} (alias for Array{typeof(f), 1})

julia> f1(x)=x+1
f1 (generic function with 1 method)

julia> typeof([f,f1])
Vector{Function} (alias for Array{Function, 1})

```

---

<div class="post-metadata">

### Author: ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)
#### Post date: [September 8, 2024, 7:37pm UTC](https://discourse.julialang.org/t/vector-function-behaves-strangely-when-length-is-one/119197/2 "2024-09-08T19:37:54Z")

</div>

`f` has type `typeof(f)` and a single-element vector chooses the most specific eltype `typeof(f)`. You can use `Function[f]` or `Any[f]` to let more callables in.

---

<div class="post-metadata">

### Author: ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)
#### Post date: [September 8, 2024, 7:57pm UTC](https://discourse.julialang.org/t/vector-function-behaves-strangely-when-length-is-one/119197/3 "2024-09-08T19:57:06Z")

</div>

Does this clear things up?

```julia-repl
julia> promote_type(typeof(sin))
typeof(sin) (singleton type of function sin, subtype of Function)

julia> promote_type(typeof(sin), typeof(cos))
Function

```

---

<div class="post-metadata">

### Author: ![Mikhail\_Kagalenko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikhail_kagalenko/32/13257_2.png) [@Mikhail\_Kagalenko](https://discourse.julialang.org/u/Mikhail_Kagalenko)
#### Post date: [September 8, 2024, 8:11pm UTC](https://discourse.julialang.org/t/vector-function-behaves-strangely-when-length-is-one/119197/4 "2024-09-08T20:11:09Z")

</div>

Yes, thank you.
