Skip to content

Instantly share code, notes, and snippets.

@malmaud
Created July 22, 2015 02:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malmaud/a0c9b4db015112c762fe to your computer and use it in GitHub Desktop.
Save malmaud/a0c9b4db015112c762fe to your computer and use it in GitHub Desktop.
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