Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Removing an element from a list
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: YAMAGATA yoriyuki <yoriyuki@m...>
Subject: Re: [Caml-list] Removing an element from a list
From: Vincent Foley <vinfoley@iquebec.com>
Subject: [Caml-list] Removing an element from a list
Date: Fri, 28 Jun 2002 15:39:52 -0400

> I would like to know how to remove an element from a list.  For example,
> I would like to remove 3 in this list: [1; 2; 3; 4; 5].  How would I do
> it?

List.filter (fun e -> e <> 3) [1; 2; 3; 4; 5]

This creates the new list [1; 2; 4; 5] and does not modify the original
[1; 2; 3; 4; 5].  In caml, operations on lists is never destructive
(unlike lisp).

--
Yamagata Yoriyuki
http://www.mars.sphere.ne.jp/yoriyuki/
-------------------
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