Version française
Home     About     Download     Resources     Contact us    
Browse thread
List comprehensions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Joel Reymont <joelr1@g...>
Subject: Re: [Caml-list] List comprehensions

On Aug 18, 2007, at 3:28 PM, Jon Harrop wrote:

> # [x + 2*x + x/2 | x <- [1; 2; 3; 4]];;
> - : int list = [3; 7; 10; 14]

How do you do something like this?

[x + 2*x + y/2 | x <- [1; 2; 3; 4], [y <- [3; 4; 5]];;

That is a list comprehension with more than one variable where all  
variables come from lists.

	Thanks, Joel

--
http://wagerlabs.com