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 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, August 18, 2002 9:32 AM
To: [EMAIL PROTECTED]
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 =  f :< as >< bs >< cs >< ds >< es >< fs

infixl  123whatever  (:<), (><)
-- lower priority than (++)

(:<) :: (a->b) -> [a] -> [b]
(:<) = map

(><) :: [(a->b)] -> [a] -> [b]
(><) = zipWith id
or better:
(><) :: [(a->b)] -> [a] -> [b]
(><) (f:fs) (x:xs) = (f x) : (fs >< xs)
(><) _ _ = []



The fibs example would now look like this:
take 10 fibs where fibs = 1 : 1 : (   (+)  :<  fibs  ><  tail fibs   )
instead of
take 10 fibs where fibs = 1 : 1 : zipWith (+) (fibs) (tail fibs)

What does you suggest/what's your oppinion to this?
(maybe other operators?)

- Marc

_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell
_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to