On 8/31/05, Krasimir Angelov <[EMAIL PROTECTED]> wrote: > 2005/8/31, Sebastian Sylvan <[EMAIL PROTECTED]>: > > On 8/31/05, Dinh Tien Tuan Anh <[EMAIL PROTECTED]> wrote: > > > > > > >Something like (untested)... > > > > > > > >xs <- zipWith ($) forkIO (map (\f -> f x y) funs) > > > >tids <- sequence xs > > > > > > > > > > > > > what does "zipWith ($)" do ? > > > > $ is function application, so zipWith ($) will "zip" a list of > > functions with a list of arguments, by applying the functions to the > > arguments pair-wise, producing a list of results. > > But forkIO is function not a list of functions. The above example is > incorrect. I think it should be: > > tids <- sequence [forkIO (f x y) | f <- funs]
The following corrects the zipWith example: xs <- zipWith ($) (repeat forkIO) (map (\f -> f x y) funs) tids <- sequence xs -- "50% of marriages today end in divorce, the other 50% end in death. Which would you rather have?" _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
