zipWith, zipWith3, zipWith4.... looks gawky, IMHO
Conal Elliott
conal@microsoft.com
Sun, 18 Aug 2002 11:07:17 -0700
Looks good to me, and very insightful for a Haskell relative newbie.
You could also use "repeat f >< as" in place of "f :< as". Or define
the latter as the former. If you think of lists as functions from
integers, then :<, ><, and repeat are the classic combinators B ("." in
Haskell), S, and K ("const" in Haskell).
Cheers,
- Conal=20
-----Original Message-----
From: Coeus@gmx.de [mailto:Coeus@gmx.de]=20
Sent: Sunday, August 18, 2002 9:32 AM
To: haskell@haskell.org
Subject: zipWith, zipWith3, zipWith4.... looks gawky, IMHO
Hi all.
I'm new to this mailing list. (and still a relative newbie in Haskell -
learning GraphicsLib)
Because the Wish List did not work (maybe it is my browsers fault), I
now
write it to this list.
I found the zipWithN functions in the standard libs, but imho it would
be
much more comfortable to use operators like in this example:
zipWith6 :: (a->b->c->d->e->f -> g) -> ([a]->[b]->[c]->[d]->[e]->[f] ->
[g])
zipWith6 f as bs cs ds es fs =3D f :< as >< bs >< cs >< ds >< es >< fs
infixl 123whatever (:<), (><)
-- lower priority than (++)
(:<) :: (a->b) -> [a] -> [b]
(:<) =3D map
(><) :: [(a->b)] -> [a] -> [b]
(><) =3D zipWith id
or better:
(><) :: [(a->b)] -> [a] -> [b]
(><) (f:fs) (x:xs) =3D (f x) : (fs >< xs)
(><) _ _ =3D []
The fibs example would now look like this:
take 10 fibs where fibs =3D 1 : 1 : ( (+) :< fibs >< tail fibs )
instead of
take 10 fibs where fibs =3D 1 : 1 : zipWith (+) (fibs) (tail fibs)
What does you suggest/what's your oppinion to this?
(maybe other operators?)
- Marc
_______________________________________________
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell