Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Jacques Carette" <carette@mcmaster.ca>
To: "'Radu Grigore'" <radugrigore@gmail.com>,
	"'caml-list'" <caml-list@inria.fr>
Subject: RE: [Caml-list] really HO Functions
Date: Wed, 29 Sep 2004 15:24:50 -0400	[thread overview]
Message-ID: <000a01c4a659$fd2f9270$1b447182@cas.mcmaster.ca> (raw)
In-Reply-To: <7f8e92aa04092911481e72dbeb@mail.gmail.com>

The best answer is from Chris Okasaki in
Even Higher-Order Functions for Parsing or Why Would Anyone Ever Want To Use
a Sixth-Order Function? by Chris Okasaki. Journal of Functional Programming,
8(2):195-199, March 1998.

Abstract: We illustrate the use of third-, fourth-, fifth-, and even
sixth-order functions with examples taken from a combinator parsing library.


Available at http://www.eecs.usma.edu/Personnel/okasaki/jfp98.ps

Jacques

-----Original Message-----
From: owner-caml-list@pauillac.inria.fr
[mailto:owner-caml-list@pauillac.inria.fr] On Behalf Of Radu Grigore
Sent: September 29, 2004 2:48 PM
To: caml-list
Subject: [Caml-list] really HO Functions


For this message I'll classify functions on "levels" based on how many
nested parenthesis are needed to represent their type.

Functions of level 0 (e.g. int -> int, char -> int -> int, ...) are the most
used in programming. In widespread languages like C#, Java and C++ they are
almost the only kind of functions used.

Functions of level 1 (e.g. ('a -> 'b) -> ('b -> 'c) -> ('a -> 'c)) are used
a lot when programming in a functional language. They are also the ones that
appear in examples and tutorials written for imperative programmers. This
category includes fold, iter, map, composition.

However a language like OCaml allows N to go up as much as you want. My
question is: are there functions of level >= 2 used in practice (e.g. (('a
-> 'b -> 'a) -> 'a -> 'b list -> 'a) -> 'c)? If so, are there any typical
ones that appear in many applications (maybe not as widespread like map &
company but at least of comparable usefulness)? One example of a level 2
function (stolen from a recent post by Jon
Harrop) is this:
  let sum fold = fold (+);;

regards,
radu

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives:
http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ:
http://caml.inria.fr/FAQ/ Beginner's list:
http://groups.yahoo.com/group/ocaml_beginners

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2004-09-29 19:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-29 18:48 Radu Grigore
2004-09-29 19:24 ` Jacques Carette [this message]
2004-09-29 22:31 ` Jon Harrop
2004-09-29 23:32   ` Marcin 'Qrczak' Kowalczyk
2004-09-30  6:27     ` Diego Olivier Fernandez Pons
2004-09-30 19:27 ` Michal Moskal
2004-09-29 20:48 Jean-Baptiste Rouquier
2004-10-02  5:02 ` Radu Grigore
2004-10-02  6:33   ` John Prevost
2004-10-02 16:44     ` Seth J. Fogarty
2004-09-30 17:30 Harrison, John R

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='000a01c4a659$fd2f9270$1b447182@cas.mcmaster.ca' \
    --to=carette@mcmaster.ca \
    --cc=caml-list@inria.fr \
    --cc=radugrigore@gmail.com \
    /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