Find in in Julai 1.0 .. LinearIndices to long

in vector los i need to find some ones
new code of julai is some comlicated :
(LinearIndices(los.==1))[findall(los.==1)]

Is some more easy to do ?
Paul

I may not have understood the problem but

los = [Int(rand()<0.5) for i in 1:10_000];
idx_1 = findall(los .== 1); # indices of where the `1` are

This gives the same result as (LinearIndices(los.==1))[findall(los.==1)] .

2 Likes

The

(LinearIndices(los.==1))[findall(los.==1)

is in hint in Julia 0.7, but is to looong :slight_smile:

Thx Paul

I myself are new to julia, but perhaps logical indexing would be an option if you need the indices just once.

los[los.==1] .= something
#or
other_similar_length[los.==1] .= something