From: "Alexander Voinov" <avoinov@gmail.com>
To: <caml-list@yquem.inria.fr>
Subject: A syntax extension to simplify List manipulation
Date: Sat, 16 Jan 2010 15:21:35 -0800 [thread overview]
Message-ID: <003801ca9702$a72e2b30$f58a8190$@com> (raw)
In-Reply-To: <4b523e9c.0d67f10a.06ab.ffffced7@mx.google.com>
Hi All,
This is a syntax extension I've been using since 2003:
http://www.voinov.org/FP/spbSyntax.tgz
It defines a number of constructs, which make List traversals look like
loops over arrays/sequences in popular languages like Python:
map [1;2;3] with e -> e + 1
filtermap [1;2;3] with e when e mod 2 == 0 -> Some e | _ -> None
foldl [1;2;3] from 0 with s0, e -> s0 + e
iterate [1;2;3] with e -> printf "%d\n" e done
and some more like this.
It relies upon camlp5 instead of (new) camlp4. It maps those constructs into
the corresponding functions of ExtLib (not the standard List module), so
that one can use tail recursion optimization.
The motivation to this syntax extension was as follows. I've been working in
bioinformatics and we have had ~10000000 lines of Python code in our CVS.
I've started to use OCaml for some applications where I needed more runtime
speed than Python could deliver and still didn't want to dive into C++. Also
I tried to promote OCaml among my Pythonic colleagues. That is why I enjoyed
a possibility to make list processing constructs looking like Python loops
over lists (that is, dynamic arrays). I've identified a number of common use
cases and mapped each of them onto an appropriate higher order function from
the Extlib library. On the caml side, these extensions look similar to the
match ... with construct.
An example code, included into the distribution show how I've been and still
am using these extensions in practical applications.
Thank you!
Alexander
next prev parent reply other threads:[~2010-01-16 23:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-16 22:33 Configuring emacs to work with caml C. Fr
2010-01-16 23:21 ` Alexander Voinov [this message]
2010-01-17 8:24 ` [Caml-list] A syntax extension to simplify List manipulation blue storm
2010-01-25 17:42 ` Damien Doligez
2010-01-25 21:45 ` Alexander Voinov
2010-01-25 22:32 ` blue storm
2010-01-26 0:14 ` Alexander Voinov
2010-01-26 0:39 ` blue storm
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='003801ca9702$a72e2b30$f58a8190$@com' \
--to=avoinov@gmail.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