-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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.)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels