Created
July 22, 2015 02:02
-
-
Save malmaud/a0c9b4db015112c762fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function f(x, N) | |
res = false | |
for n=1:N | |
res = res || (x==1 || x==2) | |
end | |
res | |
end | |
function g(x, N) | |
res =false | |
for n=1:N | |
res = res || (x in (1, 2)) | |
end | |
res | |
end | |
@time f(1, 10^7) | |
16.615 milliseconds (4 allocations: 144 bytes) | |
@time g(1, 10^7) | |
14.285 milliseconds (4 allocations: 144 bytes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment