Dear All,
Is there a neat way to find whether, in an array of custom structs, we have an entry with a specific field value or not (outputs as true
or false
)?
For example, consider the following example. I have a custom struct
defined as follows:
struct MyStruct
i::Int64 # corresponds to index i ∈ [-1:3]
j::Int64 # corresponds to index j ∈ [-1:3]
k::Int64 # corresponds to index k ∈ [0:3]
end
And I have the following array of this custom struct MyStruct
.
A = MyStruct[
MyStruct(0, 2, 0),
MyStruct(2, 0, 0),
MyStruct(2, 3, 0),
MyStruct(0, 2, 1),
MyStruct(2, 0, 1),
MyStruct(2, 3, 1),
MyStruct(0, 2, 2),
MyStruct(2, 0, 2),
MyStruct(2, 3, 2)]
As we can see, for any element of the form MyStruct(i,j,k)
of A
, MyStruct(i,j,k).k
never takes the value 3
, but takes the value 0
,1
, and 2
. Is there a way to do this programmatically for large arrays of MyStruct
s, whether in the array of custom structs a specific field value (such as k == 3
) appears or not (outputs as true
or false
) in the entries?