GHC doesn't remove intermediate lists down both
branches of a zip, so yes, you'll get intermediate lists.

Why not use array indexing, as per your second version
(only in Haskell)?

Simon

| -----Original Message-----
| From: Hal Daume III [mailto:[EMAIL PROTECTED]] 
| Sent: 16 May 2002 00:55
| To: GHC Users Mailing List
| Subject: efficiency of UArray
| 
| 
| can we expect a function like:
| 
|   sum [x*y | (x,y) <- zip (elems v) (elems u)]
| 
| to be as efficient as, say:
| 
| sum = 0
| for i=1, n
|   sum = sum + v[i] * u[i]
| 
| ?
| 
| Basically, will any intermediate lists be created here?
| 
| --
| Hal Daume III
| 
|  "Computer science is no more about computers    | [EMAIL PROTECTED]
|   than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume
| 
| _______________________________________________
| Glasgow-haskell-users mailing list 
| [EMAIL PROTECTED] 
| http://www.haskell.org/mailman/listinfo/glasgow-| haskell-users
| 
_______________________________________________
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to