English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Having '<<', why to use '|>' ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-09-17 (18:58)
From: Eric Cooper <ecc@c...>
Subject: Re: [Caml-list] Having '<<', why to use '|>' ?
On Mon, Sep 17, 2007 at 04:36:17PM +0200, Fabrice Marchant wrote:
> let ( << ) f g x = f (g x)
> let ( |> ) x f = f x
> I usually use '<<' and wonder if we can always supersede '|>' by
> this operator ?  Does it exists a case where the use of '|>' is
> better ?

I think it's just a matter of style.  Your |> operator lets you write
"pipelines" similar to the Unix shell, in which evaluation flows
from left to right.  I've typically used this when I'm applying the
function to all its arguments.  I tend to use the traditional
composition operator (your <<), when I'm combining and passing
functional values around.

-- 
Eric Cooper             e c c @ c m u . e d u