-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I've got a little function which I derived from Bird's book "Intro to
Functional Programming using Haskell".
Basically I had several instances of lists that needed outputing with all
kinds of text decoration. This function was used repeatedly throughout the
code, by removing all the cut and paste instances, this was the common
function:
output :: (a -> IO b) -> [a] -> IO ()
output f = (foldr (>>) (return ())).(map f)
So given a function that transforms a value of type 'a' into an output of 'IO'
and a list of 'a', all IO is performed across the list.
Example usage:
output f [1,2,3] where f a = putStr ("List contains "++(show a)++"\n"))
- --
List contains 1
List contains 2
List contains 3
Probably not very exciting for the old hats at Haskell, but pretty handy to
have around at my level of expertise.
Shawn
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iEYEARECAAYFAj8oIdAACgkQDtpPjAQxZ6AC0ACaA8boOZc8Hjmp9rTAyZ00lPLX
QwkAniPsBPHUvBfUcsZlU6TvF1pzkTox
=3aEG
-----END PGP SIGNATURE-----
_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe