zips and maps

Conal Elliott conal@microsoft.com
Thu, 8 Mar 2001 18:36:26 -0800


How about zipMap = zipWith ($)

       - Conal

 -----Original Message-----
From: 	Eric Allen Wohlstadter [mailto:wohlstad@cs.ucdavis.edu] 
Sent:	Thursday, March 08, 2001 6:19 PM
To:	haskell-cafe@haskell.org
Subject:	zips and maps

I find myself very often needing to use this function and was wondering if
there was already a way to do this using zip,maps, and folds.

zipMap::[a->b]->[a]->[b]
zipMap [] _ = []
zipMap _ [] = []
zipMap (f:fs) (x:xs) = (f x):(zipMap fs xs)

Alternatively I can get the same affect like this:
fstOnSnd::(a->b,a)->b
fstOnSnd (f,x) = f x

zipMap::[a->b]->[a]->[b]
zipMap fs xs = map fstOnSnd (zip fs xs)

Both require me to invent some new function (or use a lambda) which I am
trying to avoid. If it is unavoidable then can someone think of a better
name then zipMap?

	Eric Wohlstadter
	UCDavis Software Engineering





_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe