efficiency of UArray

Simon Peyton-Jones simonpj@microsoft.com
Thu, 16 May 2002 00:49:22 -0700


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