From: Jon Harrop <jon@ffconsultancy.com>
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 [thread overview]
Message-ID: <200705241908.56696.jon@ffconsultancy.com> (raw)
In-Reply-To: <6f9f8f4a0705240930t612a7ea9n725c42cbceb864f1@mail.gmail.com>
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
next prev parent reply other threads:[~2007-05-24 18:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20070522234715.0BCB2BC74@yquem.inria.fr>
2007-05-23 5:21 ` Dan Grossman
2007-05-23 8:03 ` [Caml-list] " Loup Vaillant
2007-05-23 12:51 ` David Teller
2007-05-24 16:30 ` Loup Vaillant
2007-05-24 18:08 ` Jon Harrop [this message]
2007-05-24 21:29 ` David Teller
2007-05-25 7:58 ` Loup Vaillant
2007-05-25 9:57 ` Markus E.L.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200705241908.56696.jon@ffconsultancy.com \
--to=jon@ffconsultancy.com \
--cc=caml-list@yquem.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox