From: Johann Hibschman Date: 2002-02-07T04:02:12+09:00 Subject: Re: Call/CC and Ruby iterators. timsuth@ihug.co.nz (Tim Sutherland) writes: > No. Ruby's ``iterators'' just call a closure repeatedly. The 'callcc' method > in Ruby is equivalent to Scheme's call/cc. > > Ruby > [1, 2, 3].map { |x| x+1 } > Scheme > (map (lambda (x) (+ x 1)) (list 1 2 3)) No, this isn't quite true. Ruby iterators define "break" (to stop the iteration) and "next" to skip to the next iteration. This is harder to do with continuations. i.e. > 10.times {|i| puts i; next if i == 2; break if i == 4; puts 'foo'} 0 foo 1 foo 2 3 foo 4 nil How would you do this in Scheme? --Johann