From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA22637; Wed, 19 Jun 2002 19:22:32 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA22638 for ; Wed, 19 Jun 2002 19:22:32 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from athlon.baretta.com (r-mi214-6a5.tin.it [62.211.4.5]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g5JHMUj16195 for ; Wed, 19 Jun 2002 19:22:31 +0200 (MET DST) Received: from baretta.com (localhost.localdomain [127.0.0.1]) by athlon.baretta.com (Postfix) with ESMTP id 7992A273CE; Wed, 19 Jun 2002 19:27:15 +0200 (CEST) Message-ID: <3D10BEEE.4030806@baretta.com> Date: Wed, 19 Jun 2002 19:27:10 +0200 From: Alessandro Baretta Organization: Baretta srl -- www.baretta.com User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0rc1) Gecko/20020417 X-Accept-Language: it, en MIME-Version: 1.0 To: Johann Spies Cc: caml-list@inria.fr Subject: Re: [Caml-list] List.sort References: <20020619085454.GA5244@adept.co.za> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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