Newsgroups: fa.caml
From: "Till Varoquaux" <till.varoqu...@gmail.com>
Date: Mon, 13 Nov 2006 16:24:18 UTC
Local: Mon, Nov 13 2006 11:24 am
Subject: Re: [Caml-list] Simple idea for making a function infix
Hi,
I don't really understand the point of the */ operator i your On 11/13/06, Keisuke Nakano <k...@mist.i.u-tokyo.ac.jp> wrote: > Hi all, Hi, > Haskell people sometimes complain about that OCaml cannot make an > Here is a simple idea for making a function infix in OCaml. > We use the following two infix operators. > let ( /* ) x y = y x > Then we can make an infix operator /*f*/ for a binary function f. > 3 /*min*/ 4 + 6 /*max*/ 8 > to get 11 as 'min 3 4 + max 5 8'. Note that the infix operator > You have to take care of the precedence. For example, > 3 /*min*/ 4 * 6 /*max*/ 8 > will return 18 as 'max ((min 3 4) * 6) 8'. So we should write > (3 /*min*/ 4) * (6 /*max*/ 8) > to get 24 as 'min 3 4 * max 6 8'. > The original idea was introduced in my blog a few months ago > let ( <| ) x y = y x > or > let ( @^ ) x y = y x > where the definition of ( ^@ ) should be given in a different way > 3 <|min|> 4 + 6 <|max|> 8 (* = max (min 3 (4 + 6)) 8 => 8 *) > So you have to write > (3 <|min|> 4) + (6 <|max|> 8) > to get 11 as min 3 4 + max 5 8'. > Sincerely, > ----------------------------------------------------------------------- > _______________________________________________ I don't really understand the point of (*/) in your solution (maybe ( * might interact badly with camlp4 *) let plus a b= a+b;; 4 $plus 4;; _______________________________________________ You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||