From: Alessandro Baretta <alex@baretta.com>
To: Johann Spies <jspies@sun.ac.za>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] List.sort
Date: Wed, 19 Jun 2002 19:27:10 +0200 [thread overview]
Message-ID: <3D10BEEE.4030806@baretta.com> (raw)
In-Reply-To: <20020619085454.GA5244@adept.co.za>
Johann Spies wrote:
>
> According to the manual the Persvasives.compare function is suitable
> to use with List.sort. I can't figure out how to use it:
> ----------------------------
> # k;;
> - : int list = [3; 2; 1]
> # List.sort (compare 1 2) k;;
> This expression has type int but is here used with type 'a -> 'a ->
> int ...
Objective Caml version 3.04+13 (2002-06-05)
# let k = [ 3; 2 ; 1];;
val k : int list = [3; 2; 1]
# List.sort compare k;;
- : int list = [1; 2; 3]
Does this solve your problem? You have to realize that
functions (like Pervasives.compare) are first class citizens
in O'Caml. That is, you can pass a function like List.sort
*another function* as a actual parameter.
This is a fairly elementary question. You should try to
avoid posting questions like this on this list; however, I
am more than willing to lend a hand, insofar as possible, so
you can write to me personally, but please mention "Caml" in
the subject.
Alex
-------------------
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
next prev parent reply other threads:[~2002-06-19 17:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-06-19 8:54 Johann Spies
2002-06-19 15:14 ` Stefano Zacchiroli
2002-06-19 15:16 ` Henri Dubois-Ferriere
2002-06-19 15:30 ` sebastien FURIC
2002-06-19 15:26 ` Remi VANICAT
2002-06-19 17:27 ` Alessandro Baretta [this message]
2002-06-20 9:29 ` Johann Spies
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=3D10BEEE.4030806@baretta.com \
--to=alex@baretta.com \
--cc=caml-list@inria.fr \
--cc=jspies@sun.ac.za \
/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