Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] [camlp4] compiling against Pcaml module
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-10-17 (16:39)
From: Alexander V.Voinov <avv@q...>
Subject: [Caml-list] a quick question on camlp4

For a presentation which I'm about to make, I created a 
simple (normal) syntax extension to imitate Python loop
over a sequnce:

iterate <list> with <fun> which maps to List.iter <fun> <list>.

This results in examples like:

iterate [1; 2; 3; 4] with function
  | 2 -> printf "two\n"
  | n -> printf "%d\n"

Is it possible to eliminate the keyword 'function' from this,
that is to implement an extension like:

iterate <list> with <pat1> -> <expr1> | <pat2> -> <expr2> ...

mapping to

List.iter (function <pat1> -> <expr1> | <pat2> -> <expr2> ...) <list>.

I'm asking this just because I don't have time now to investigate
this by my own :-).

Also, I was thinking about extensions like

let sum = 
   fold [10; 20; 30; 40] from 0.0 with
     | val, sum -> val + sum

mapping to fold_left/fold_right.

Thank you in advance

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: