Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Arrays with no size and/or non-sequential integers

$
0
0

I just stumbled on two phrases in the manual that puzzle me:

In https://docs.julialang.org/en/v1/base/arrays/#Base.size it says

Note that size may not be defined for arrays with non-standard indices, in which case axes may be useful. See the manual chapter on arrays with custom indices.

What kind of array doesn’t have a size defined? I can’t find an example, and the “chapter on arrays with custom indices” only says:

In some cases it may also be helpful to temporarily disable size and length for your new array type, since code that makes incorrect assumptions frequently uses these functions.

which sounds more like a temporary debug thing than a real array without size.

The other phrase is at https://docs.julialang.org/en/v1/devdocs/offset-arrays/#Linear-indexing-(LinearIndices)-1 :

For this reason, your best option may be to iterate over the array with eachindex(A) , or, if you require the indices to be sequential integers, to get the index range by calling LinearIndices(A) .

In which case would eachindex(A) give values that are not sequential integers?

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Latest Images

Trending Articles