From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id F1A86BBAF for ; Tue, 2 Feb 2010 05:27:28 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvMAABc5Z0vLOwFomWdsb2JhbACbSQEBAQEBCAsKBxO8YIRFBA X-IronPort-AV: E=Sophos;i="4.49,387,1262559600"; d="scan'208";a="42647977" Received: from outbound.icp-qv1-irony-out4.iinet.net.au ([203.59.1.104]) by mail2-smtp-roc.national.inria.fr with ESMTP; 02 Feb 2010 05:27:11 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEACY4Z0vLzuai/2dsb2JhbADYaYRFBA X-IronPort-AV: E=Sophos;i="4.49,387,1262534400"; d="scan'208";a="502599843" Received: from unknown (HELO hendrix.mega-nerd.net) ([203.206.230.162]) by outbound.icp-qv1-irony-out4.iinet.net.au with ESMTP; 02 Feb 2010 12:27:08 +0800 Received: from hendrix.mnn (hendrix.mnn [192.168.200.99]) by hendrix.mega-nerd.net (Postfix) with SMTP id E9A89106FA6 for ; Tue, 2 Feb 2010 15:27:07 +1100 (EST) Date: Tue, 2 Feb 2010 15:27:07 +1100 From: Erik de Castro Lopo To: caml-list@inria.fr Subject: Re: [Caml-list] New to Ocaml Message-Id: <20100202152707.8f4a1e24.mle+ocaml@mega-nerd.com> In-Reply-To: References: Reply-To: caml-list@inria.fr Organization: Erik Conspiracy Secret Labs X-Mailer: Sylpheed 2.6.0 (GTK+ 2.16.1; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ocaml:01 ocaml:01 wrote:01 caml-list:01 immutable:01 let:03 erik:04 erik:04 linked:07 linked:07 similarly:08 function:08 suppose:09 example:10 sort:12 chaithanya kr wrote: > Hi all. I am new to Ocaml. Just started learning recently. > > I was studying lists in ocaml. In that, suppose there is a list by name > singly_list, then by saying "List.length singly_list;;" I will get the > length of the linked list. > > Similarly can anyone tell me as to how to sort a linked list using the > 'sort' function? Please give me an example of using List.sort. In Ocaml, lists are immutable (cannot be changed) and hence, sorting a list results in a new list: let sorted_list = List.sort unsorted_list in .... Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/