イテレータ

これくらいで、イテレータが云々とか言っているのはなんだかなぁ、とか思ったりしないでもない。なので、あえて Ruby 以外で。
Haskell で。

hello :: String -> [String] -> IO ()
hello to msg = do putStrLn $ "Hello, " ++ to ++ "."
                  putStrLn "-- message --"
                  mapM_ putStrLn msg

fact :: Int -> Int
fact n = foldl (*) 1 [1..n]

Python で。

import operator

def hello(to, *msg):
    print 'Hello, %s' % to
    print '-- message --'
    for m in msg: print m

def fact(n):
    return reduce(operator.mul, xrange(1, n + 1), 1)