Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Alain Frisch <frisch@clipper.ens.fr>
To: Julian Assange <proff@iq.org>
Cc: caml-list@inria.fr
Subject: Re: list composition functions
Date: Mon, 16 Oct 2000 09:58:00 +0200 (MET DST)	[thread overview]
Message-ID: <Pine.GSO.4.04.10010160953380.25478-100000@clipper.ens.fr> (raw)
In-Reply-To: <wxg0lxisdw.fsf@foo.iq.org>

On 16 Oct 2000, Julian Assange wrote:
> Imagine you have the follow three functions,
> 
> let mirror x = [x;x]
> let plus1 x = [x+1]
> let none x = []
> 
> I'm trying to define an operator (>>) that will then operate like so
> 
> (mirror >> mirror >> plus1) [1]
> 
> [2;2;2;2]

You could try something like:

let build_transformer f x =
    List.concat (List.map f x)

let (>>) t1 t2 x =
    t1 (t2 x)

let mirror = build_transformer (fun x -> [x;x])
let plus1  = build_transformer (fun x -> [x+1])
let none   = build_transformer (fun x -> [])


(mirror and none are not generalized since their definition
is expansive)


-- 
  Alain Frisch



  parent reply	other threads:[~2000-10-16 12:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-10-15 23:42 Julian Assange
2000-10-16  6:57 ` Jacques Garrigue
2000-10-16  7:58 ` Alain Frisch [this message]
2000-10-16 12:22   ` Julian Assange

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=Pine.GSO.4.04.10010160953380.25478-100000@clipper.ens.fr \
    --to=frisch@clipper.ens.fr \
    --cc=caml-list@inria.fr \
    --cc=proff@iq.org \
    /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