我怎样才能从 Julia 中的数组中删除多行?

How could I eliminate more than one row from array in an Julia?

function prealloc()
    situation=zeros(Int64,3^5,5);
    i=1;
    for north=0:2, south=0:2, east=0:2, west=0:2, current=0:2
        situation[i,:]=[north, south, east, west, current]
        i+=1
    end
    situation
end
prealloc()

如何在 Julia 中从数组中删除多行?

您可以使用逻辑索引或整数索引。例如,

function eliminate_matching_rows(A, pattern)
    keep = [A[i,:] != pattern for i = 1:size(A,1)]
    A[keep, :]
end

将消除 A 中与 pattern.

匹配的所有行