From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 56C45BC0A for ; Thu, 24 May 2007 20:14:36 +0200 (CEST) Received: from ptb-relay03.plus.net (ptb-relay03.plus.net [212.159.14.214]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l4OIEZCA004976 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Thu, 24 May 2007 20:14:36 +0200 Received: from [80.229.56.224] (helo=beast.local) by ptb-relay03.plus.net with esmtp (Exim) id 1HrHpb-0003jl-2v for caml-list@yquem.inria.fr; Thu, 24 May 2007 19:14:35 +0100 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Re: Teaching bottomline, part 3: what should improve. Date: Thu, 24 May 2007 19:08:56 +0100 User-Agent: KMail/1.9.7 References: <20070522234715.0BCB2BC74@yquem.inria.fr> <1179924683.6966.90.camel@Blefuscu> <6f9f8f4a0705240930t612a7ea9n725c42cbceb864f1@mail.gmail.com> In-Reply-To: <6f9f8f4a0705240930t612a7ea9n725c42cbceb864f1@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200705241908.56696.jon@ffconsultancy.com> X-Miltered: at discorde with ID 4655D60B.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; arrays:01 arrays:01 syntax:01 haskell:01 syntax:01 factorial:01 factorial:01 seq:01 fsharp:01 increments:98 frog:98 wrote:01 syntactic:01 caml-list:01 functions:01 On Thursday 24 May 2007 17:30:56 Loup Vaillant wrote: > It sounds like you need some kind of macro which can encapsulate a > chunk of code into an anonymous function like : Might be worth going F# compatible here: > for_each i : my_list > begin > i*2 > end > (* map (fun i -> i*2) my_list *) [for i in my_list -> i*2] To be honest, this kind of syntactic sugar doesn't wash with me. I just end up using functions everywhere. > Problem : works only on lists (or arrays, depending of your choice). You can generate arrays and lazy sequences using a slightly different syntax: [|for i in my_list -> i*2|] {for i in my_list -> i*2} > And a Haskell like syntax for creating lists would help. (something > like [0..10]). Range comprehensions: [0 .. 10] Also, with increments: [10 .. -2 .. 0] And over lazy sequences, hence the factorial example: let factorial n = Seq.fold ( * ) 1 {2 .. n} -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. The F#.NET Journal http://www.ffconsultancy.com/products/fsharp_journal/?e