Browse thread
Simple idea for making a function infix
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2006-11-13 (17:58) |
From: | skaller <skaller@u...> |
Subject: | Re: [Caml-list] Simple idea for making a function infix |
On Mon, 2006-11-13 at 17:19 +0100, Till Varoquaux wrote: > Hi, > > I don't really understand the point of the */ operator i your > definition. It's fuy ecause I've cosiderig the same problem recetly ad > came dow to this approach ( I'm redefining(@)... oe c ) > > let ( /* ) x y = y x > > and ( */ ) x y = x y The point is precedence: consider only /* then x /* f y means x /* (f y) whereas x /* f */ y means (f x) y Of course x /* f */ y z means f x (y z) but then x + y z also means (+) x (y z) Also you can write x /* g h */ y which means (g h) x y which is kind of cute, eg: [] /* List.fold_left (fun x y -> y::x) */ [1;2;3] -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net