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中从数组中删除多行?
答案 0 :(得分:3)
您可以使用逻辑索引或整数索引。例如,
function eliminate_matching_rows(A, pattern)
keep = [A[i,:] != pattern for i = 1:size(A,1)]
A[keep, :]
end
将消除A
中与pattern
匹配的所有行。