[erlang-questions] removing an element from a list
Tue May 3 11:27:56 CEST 2011
I think I might switch to the longhand version for readability (not to
mention I've been subtracting all this time when I should have been
On 03/05/2011 10:15, Mazen Harake wrote:
> They are equally "good".
> A -- [q] says "remove all occurrences found in the right list from the
> left list". This is sugar syntax for lists:subtract/2. A -- [q,w]
> would produce [e,r,t,y].
> lists:delete(q, A) says remote element q from list A (note: only one
> The simple answer is: They are almost the same. if you only want to
> remove 1 element the list then use delete, if you want to remove
> several then use subtract.
> note: both functions only remove the first occurrence of the element,
> E.g. [a,a,b,c] -- [a] will result in [a,b,c] and _not_ [b, c], same
> behaviour for delete.
> On 3 May 2011 11:04, Ivan Uemlianin <
> <mailto:>> wrote:
> Dear All
> It seems there are two ways to remove an element from a list:
> 1> A = [q,w,e,r,t,y].
> 2> A -- [q].
> 3> lists:delete(q, A).
> Which is better, and why, or is TMTOWTDI? (I'm sure the answer
> won't be as simple as the question:).
> With thanks and best wishes
> Ivan A. Uemlianin
> Speech Technology Research and Development
> www.llaisdy.com <http://www.llaisdy.com>
> llaisdy.wordpress.com <http://llaisdy.wordpress.com>
> "Froh, froh! Wie seine Sonnen, seine Sonnen fliegen"
> (Schiller, Beethoven)
> erlang-questions mailing list
Ivan A. Uemlianin
Speech Technology Research and Development
"Froh, froh! Wie seine Sonnen, seine Sonnen fliegen"
More information about the erlang-questions