# \[ANN\] IndexFunArrays.jl - Fun with indices (and functions on them)

**URL:** <https://discourse.julialang.org/t/ann-indexfunarrays-jl-fun-with-indices-and-functions-on-them/57862>\
**Category:** Package Announcements\
**Tags:** package, array\
**Created:** [March 24, 2021, 11:54am UTC](https://discourse.julialang.org/t/ann-indexfunarrays-jl-fun-with-indices-and-functions-on-them/57862 "2021-03-24T11:54:03Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![affans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/affans/32/11911_2.png) [@affans](https://discourse.julialang.org/u/affans)\
**Post date:** [March 25, 2021, 3:21pm UTC](https://discourse.julialang.org/t/ann-indexfunarrays-jl-fun-with-indices-and-functions-on-them/57862/21 "2021-03-25T15:21:17Z")

</div>

Thank you everyone, and my apologies for turning this thread into a tutorial. I do have one last question:

We know the field `generator` is a function so why give it a generic type parameter? So for example, instead of

```julia
struct IndexFunArray{T, N, F} <: AbstractArray{T, N} where {F}
    # stores the generator function to be applied to the indices. 
    generator::F
end

```

isn’t it better to do

```julia
struct IndexFunArray{T, N} <: AbstractArray{T, N}
    # stores the generator function to be applied to the indices. 
    generator::Function
end

```

---

<div class="post-metadata">

**Author:** ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)\
**Post date:** [March 26, 2021, 8:16am UTC](https://discourse.julialang.org/t/ann-indexfunarrays-jl-fun-with-indices-and-functions-on-them/57862/22 "2021-03-26T08:16:37Z")

</div>

On the contrary: `Function` is an abstract type, while `F` is a type parameter which represents the concrete type of the `generator` function (each function has its own type).

---

<div class="post-metadata">

**Author:** ![roflmaostc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/roflmaostc/32/30123_2.png) [@roflmaostc](https://discourse.julialang.org/u/roflmaostc)\
**Post date:** [April 2, 2021, 5:44pm UTC](https://discourse.julialang.org/t/ann-indexfunarrays-jl-fun-with-indices-and-functions-on-them/57862/23 "2021-04-02T17:44:13Z")

</div>

To be honest, I don’t know why we put the concrete type instead of function. But as @sijo mentioned, it might have some advantages when using concrete types in structs especially since we want the IndexFunArray to be fast.

[Previous page](https://discourse.julialang.org/t/ann-indexfunarrays-jl-fun-with-indices-and-functions-on-them/57862.md?page=1)
