B = (L .== L[1:1])

On Monday, 5 October 2015 22:34:35 UTC+10, Maxim Berman wrote:
>
> Hello,
>
> I tried to use element-wise equality on list-of-lists in julia:
>
> L = Vector{Int}[[1,2],[2,3]]
> B = (L .== L[1])
>
> However, due to .== broadcasting, this last expression performs an 
> elementwise operation on the two arrays, and therefore returns [false, 
> false]. I don't believe there is a way to circumvent this behavior, since 
> .== is meant to do both array-to-element and array-to-arrays 
> comparison... This means that we cannot simply use
> L[L .!= L[1]]
> to select elements that are not L[1].  In this case, I guess we can use 
> L[1:end 
> .!= 1]. 
>
> I have no particular issue with this, just wanted to know what was thought 
> of this behavior, which can be slightly unintuitive.
>
>

Reply via email to