You could so something like the following:

```
using Base.Iterators
using Memoize
@memoize function A(nrow::Integer, ncol::Integer)::Matrix{Function}
map(args -> bell_polynomial(args...), product(1:nrow, 1:ncol))
end
function bell_polynomial(m::Integer, j::Integer)
function(x::Vector{<:Real})
# Polynomial expression in x, given m and j
end
end
```

Here `bell_polynomial()`

is a function that returns a function, and `A()`

returns an `nrow`

by `ncol`

matrix of those functions. Note that `args -> bell_polynomial(args...)`

is there to splat the `(n, k)`

pairs returned by `product(1:nrow, 1:ncol)`

to the arguments of `bell_polynomial()`

. There’s probably a cleaner way to do this, but this does work.

Depending on your usage, it might be more performant to memoize `bell_polynomial()`

instead of `A()`

. It probably isn’t helpful (and might be harmful) to memoize both. But it should be pretty easy to check.

Edit: I originally `collect()`

ed the iterator returned by `product(1:nrow, 1:ncol)`

, but it turns out that’s not needed.