From: Julian Assange <proff@iq.org>
To: caml-list@inria.fr
Cc: proff@iq.org
Subject: list composition functions
Date: 16 Oct 2000 10:42:03 +1100 [thread overview]
Message-ID: <wxg0lxisdw.fsf@foo.iq.org> (raw)
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]
let (>>) a b = function x ->
let rec loop = function
[] -> []
| hd::tl ->
let rec loop2 = function
[] -> loop tl
| hd::tl -> b hd @ loop2 tl
in
loop2 (a hd)
in
loop x
# (>>);;
- : ('a -> 'b list) -> ('b -> 'c list) -> 'a list -> 'c list = <fun>
While this looks okay, and works fine for two applications, the list
type keeps on growing with each partial application.
plus1 >> plus1 >> plus1 >> plus1;;
- : int list list list -> int list = <fun>
#
Is there anyway I can prevent this, short of making plus1, etc symmetric
with respect to their argument types?
next reply other threads:[~2000-10-16 6:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-10-15 23:42 Julian Assange [this message]
2000-10-16 6:57 ` Jacques Garrigue
2000-10-16 7:58 ` Alain Frisch
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=wxg0lxisdw.fsf@foo.iq.org \
--to=proff@iq.org \
--cc=caml-list@inria.fr \
/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