How to create a list/vector/matrix of specified size, each value filled with -Inf or Inf?

Hi all,
Is there a way to create a vector or list or matrix of specified size, all of them initialized to either of the infinity values? There are functions for zeros, ones and so on. I was wondering if there is one for Inf and if not how to create such a object?

For a vector or matrix you can use fill

julia> fill(-Inf, 5)
5-element Vector{Float64}:
 -Inf
 -Inf
 -Inf
 -Inf
 -Inf

julia> fill(Inf, (5, 2))
5×2 Matrix{Float64}:
 Inf  Inf
 Inf  Inf
 Inf  Inf
 Inf  Inf
 Inf  Inf


2 Likes

Thanks! This works.