Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

any and all are bitwise? #11540

Closed
JeffBezanson opened this issue Jun 2, 2015 · 8 comments
Closed

any and all are bitwise? #11540

JeffBezanson opened this issue Jun 2, 2015 · 8 comments
Labels
help wanted Indicates that a maintainer wants help on an issue or pull request

Comments

@JeffBezanson
Copy link
Sponsor Member

I didn't expect this, and I suspect it's unintentional:

julia> all([1,3,5,7])
1

julia> all([9,12,14,15])
8
@ScottPJones
Copy link
Contributor

The code (in reduce.jl, 333/334), and in functors.jl, looks intentional... AndFun() = x & y, OrFun() = x | y

@JeffBezanson
Copy link
Sponsor Member Author

Eh, I wouldn't put much stock in that. The author might have meant

call(::AndFun, x::Bool, y::Bool) = x & y

or meant to use &&.

@ScottPJones
Copy link
Contributor

From the functors around them, it didn't look that way, but of course, I could be mistaken...

@ScottPJones
Copy link
Contributor

I'm not saying either that it was correct, just that it looks intentional!

@PythonNut
Copy link
Contributor

Are any and all meant for the same uses as Python's any and all?

@hayd
Copy link
Member

hayd commented Jun 2, 2015

I hope not, julia doesn't covert to Bool as fast and loose as python. You should explicitly write:

all(a .!= 0)  # or
all([x != 0 for x in a]) # better perf when julia gets generators and can drop the [] ?

to get the python behaviour.

@StefanKarpinski
Copy link
Sponsor Member

Similar to #10838

@kmsquire kmsquire added help wanted Indicates that a maintainer wants help on an issue or pull request good first issue Indicates a good issue for first-time contributors to Julia labels Jun 4, 2015
@ihnorton ihnorton removed the good first issue Indicates a good issue for first-time contributors to Julia label Jul 10, 2015
@fcard
Copy link
Contributor

fcard commented Jul 29, 2015

Bitwise any/all have been deprecated by #11774.

@pao pao closed this as completed Jul 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Indicates that a maintainer wants help on an issue or pull request
Projects
None yet
Development

No branches or pull requests

9 participants