List comprehensions
Oliver Braun
obraun@unsane.org
Thu, 30 Jan 2003 12:14:55 +0100
--6c2NcOVqGQ03X4Wi
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
* Rijk J. C. van Haaften <rjchaaft@cs.uu.nl> [2003-01-30 12:06 +0100]:
> >* Rijk J. C. van Haaften <rjchaaft@cs.uu.nl> [2003-01-30 11:41 +0100]:
> >
> >> Recently, I came accross this expression:
> >> [ x + y | x <- xs | y <- ys ]
> > ^
> > Put a comma ',' here.
> That's something totally different. Two examples:
> 1. Comma
> [ x + y | x <- [1,2], y <- [3,4] ]
> =3D [4,5,5,6]
> 2. Bar
> [ x + y | x <- [1,2] | y <- [3,4] ]
> =3D [ x + y | (x,y) <- zip [1,2] [3,4] ]
> =3D zipWith (+) [1,2] [3,4]
> =3D [4,6]
> The first is according to the standard. No problems so far.
> However, I couldn't find a description of the semantics of
> the second (and it is clearly non-standard), though I think
> the semantics given above using zip and zipWith are correct.
Ok, I see. Sorry, this was just my first thought.
Unfortunately I cannot help you with the Bar thing.
Regards,
Olli
--=20
obraun@ -+-[ informatik.unibw-muenchen.de ]-+-[ IIS _ INF _ UniBwM ]
|-[ FreeBSD.org ]-+-[ FreeBSD Commmitter ]
|-[ unsane.org ]-+-[ everything __ else ]
--6c2NcOVqGQ03X4Wi
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (FreeBSD)
iD8DBQE+OQkvwLFrfe8lsboRAtqjAJ0ZTxWMIdbfrOJKNIR6gcBA9eAFxgCfY0IB
xZJrLp1bMNcaGHADWO2HHDc=
=gf+t
-----END PGP SIGNATURE-----
--6c2NcOVqGQ03X4Wi--