&
does not broadcast, and there is no .&
(similar problem for "or") #6915
Closed
Description
Given two logical arrays with different dimensions, there seems to be no straightforward way to broadcast and
:
a = [1:10] .< 7
b = [1:10]' .> 3
a & b # ERROR: dimensions must match
a .& b # ERROR: syntax: extra token "b" after end of expression
a && b # ERROR: type: non-boolean (BitArray{1}) used in boolean context
a .&& b # ERROR: syntax: invalid identifier name "&&"
See also discussion on the users list. It turns out a .* b
achieves the desired effect. For consistency, I suggest adding a dotted version .&
that works just like .*
. The latter works, but it's a counterintuitive way to express the intention of broadcasting and, and it relies on the fact that booleans happen to be represented by 0 and 1. There also is no corresponding way to express "broadcasting or" without resorting to tricks relying on the underlying representation, so I'd like to suggest adding .|
as well. (And/or adding .&&
and .||
, if that makes more sense.)
Metadata
Assignees
Labels
No labels