From: skaller <skaller@users.sourceforge.net>
To: Jon Harrop <jon@jdh30.plus.com>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Are map and iter guaranteed to be called in forwards order?
Date: 18 Aug 2004 15:11:09 +1000 [thread overview]
Message-ID: <1092805868.29139.1237.camel@pelican.wigram> (raw)
In-Reply-To: <200408180157.58200.jon@jdh30.plus.com>
On Wed, 2004-08-18 at 10:57, Jon Harrop wrote:
> On Tuesday 17 August 2004 15:26, John Prevost wrote:
> let index l =
> List.rev (snd (List.fold_left (fun (i, l) e -> i+1, (i, e)::l) (0, []) l));;
> Ha! Try writing that in Felix (in another mailing-list, of course ;-).
Unfair to make that challange and deny the right to a response :)
So you get it: its much the same as the Caml version except
the type annotations on the arguments are mandatory in Felix:
fun index[t] (l:list[t]) =>
rev (snd (
fold_left
(fun (i:int, l: list [t], e: int * t) =>
i+1, Cons ((i, e),l)
)
(0, Empty[t])
l
))
;
The actual code above doesn't compile due to a bug,
so I'm glad of the example -- thanks! [Looks like
I forgot to alpha convert before unifying during
overload resolution]
However its *should* work: What Caml can do and Felix cannot,
is pass a *polymorphic* function as an argument. Caml allows
that -- but then you can only use it monomorphically
[unless you wrap it in a record].
--
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850,
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2004-08-18 5:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-17 12:00 Richard Jones
2004-08-17 12:45 ` Damien Doligez
2004-08-17 14:26 ` John Prevost
2004-08-17 14:56 ` Richard Jones
2004-08-17 15:13 ` Anil Madhavapeddy
2004-08-17 15:17 ` Jean-Marie Gaillourdert
2004-08-17 15:19 ` John Prevost
2004-08-18 0:57 ` Jon Harrop
2004-08-18 5:11 ` skaller [this message]
2004-08-18 7:10 ` skaller
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=1092805868.29139.1237.camel@pelican.wigram \
--to=skaller@users.sourceforge.net \
--cc=caml-list@inria.fr \
--cc=jon@jdh30.plus.com \
/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