I want to apply function f() over a range of value. f() returns true for 
success and false for failure. Since f() is expensive, I want short circuit 
computation, i.e. it stops after the first failure. 

In python, I can do this in an elegant way with the all() function and 
generator expression.

if all(f(x) for x in values)
  # success
else
  # failure

>From what I understand, there is no generator expression in Julia. List 
comprehension will evaluate the full list. Even if I try to use for loop, I 
can't use the control variable to check if the loop has run to finish or 
not.

i = 0
for i in 1:length(values)
    if !f(values[i])
      break
   end
end
# The status is ambiguous if i==length(values) 

My last resort is to add flags to indicate if is success or not. Is there 
some more elegant way to do this?

Reply via email to