Re: Stdlib regularity

From: Matías Giovannini (matias@k-bell.com)
Date: Fri Oct 08 1999 - 16:06:10 MET DST


Date: Fri, 08 Oct 1999 11:06:10 -0300
From: =?iso-8859-1?Q?Mat=EDas?= Giovannini <matias@k-bell.com>
To: OCAML <caml-list@inria.fr>
Subject: Re: Stdlib regularity

Markus Mottl wrote:
>
> > I have used OCaml extensively in the past few years, and I've had
> > some misgivings about the CAML standard library argument ordering. It
> > is a little bit confusing and not standard. For example:
>
> Although the standard library is quite ok, there are some (minor)
> inconsistencies. What concerns my wishes for it, I'd love to see more
> features (= functions or even modules).

Yes! Yes! I always begin my Caml code by writing iota, and I wish it
were included in the standard library. It's silly simple, and imprescindible.

let iota n =
    let rec aux l n =
        if n > 0 then aux (n::l) (n-1) else l
    in aux [] n

And then a "functional for" loop looks like

List.map (fun i -> ...) (iota n)

(Incidentaly, the name "iota" comes from APL, and stands for the
"Initial natural Interval".)

-- 
I got your message. I couldn't read it. It was a cryptogram.
-- Laurie Anderson



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:26 MET