It's a naïve implementation of what you wrote in Ruby. It should work, however I didn't try it. It is not really optimal, as there is no return in my code. Anyway, it's quick and dirty...
Sure, ccc is here for that. Let's say we want the equivalent of this Python code :
def a:
for i in (1, 2, 3):
if i < 2:
return i
return None
It can be written this way in Arc :
(def a (return)
(each i '(1 2 3)
(if (< i 2)
(return i)))
nil)
arc> (ccc a)
1
To those who don't know ccc : in this code, return is not a defined macro or function, it is the current continuation, waiting for a value. We could have called it another way, k for example.
Once you "throw" it a value (i in this case), it's happy and goes on to the next calculation. (ccc a) thus tells to perform a and, once the return parameter is called, exit a and go back to the REPL (with the specified value).
Thanks for the quick reply. That seems like an awkward way to accomplish a simple thing - Python & Ruby win on this IMO.
I submitted a new article ( http://arclanguage.com/item?id=4431 ) on the topic. It might be good to re-post your comment there and have followups on that thread.