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 QAA18842; Wed, 19 Jun 2002 16:55:58 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA18710 for ; Wed, 19 Jun 2002 16:55:57 +0200 (MET DST) Received: from maties1.sun.ac.za (maties1.sun.ac.za [146.232.128.1]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g5JEtqj26187 for ; Wed, 19 Jun 2002 16:55:55 +0200 (MET DST) Received: from bywoner.sun.ac.za ([146.232.129.121] helo=bywoner) by maties1.sun.ac.za with esmtp (Exim 4.05) id 17KbEt-0008Cc-00 for caml-list@inria.fr; Wed, 19 Jun 2002 10:54:55 +0200 Received: from js by bywoner with local (Exim 3.35 #1 (Debian)) id 17KbEs-0001Mn-00 for ; Wed, 19 Jun 2002 10:54:54 +0200 Date: Wed, 19 Jun 2002 10:54:54 +0200 From: Johann Spies To: caml-list@inria.fr Subject: [Caml-list] List.sort Message-ID: <20020619085454.GA5244@adept.co.za> Mail-Followup-To: Johann Spies , caml-list@inria.fr Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.28i X-Scanner: exiscan for exim4 (http://duncanthrax.net/exiscan/) *17KbEt-0008Cc-00*r.Z43vXl/qo* Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I apologise for asking a newbie question on this list, but the beginners-list seems to have a problem. After 24 hours my message did not appear on the list and there was actually no activity the last few days. I am trying to figure out how to use List.sort. 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 # List.sort (+) k;; - : int list = [1; 2; 3] # a;; - : char list = ['d'; 'b'; 'g'] # List.sort (+) a;; This expression has type char list but is here used with type int list # List.sort (compare 'a' 'b') a;; This expression has type int but is here used with type 'a -> 'a -> int # compare 'a' 'b';; - : int = -1 # --------------------- What is confusing to me is that the manual says: "Sort a list in increasing order according to a comparison function. The comparison function must return 0 if it arguments compare as equal, a positive integer if the first is greater, and a negative integer if the first is smaller. For example, the compare function is a suitable comparison function. " I could not find a single example on how to use this function in the manual. Can somebody show me how to use it please? Johann -- Johann Spies Telefoon: 021-808 4036 Informasietegnologie, Universiteit van Stellenbosch "My son, if sinners entice thee, consent thou not." Proverbs 1:10 ------------------- 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