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/

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to