[erlang-questions] removing an element from a list

zambal <>
Tue May 3 12:16:08 CEST 2011


Maybe it's just this particular example, but if it's always the first
element in a list that needs to be removed, this is probably the
fasted:

1> A = [q,w,e,r,t,y].
[q,w,e,r,t,y]
2> [_|B] = A.
[q,w,e,r,t,y]
3> B.
[w,e,r,t,y]

--
Vincent


On May 3, 11:04 am, Ivan Uemlianin <> wrote:
> Dear All
>
> It seems there are two ways to remove an element from a list:
>
>     1> A = [q,w,e,r,t,y].
>     [q,w,e,r,t,y]
>     2> A -- [q].
>     [w,e,r,t,y]
>     3> lists:delete(q, A).
>     [w,e,r,t,y]
>     4>
>
> 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
>
> --
> ============================================================
> Ivan A. Uemlianin
> Speech Technology Research and Development
>
>                      
>                      www.llaisdy.com
>                           llaisdy.wordpress.com
>                      www.linkedin.com/in/ivanuemlianin
>
>      "Froh, froh! Wie seine Sonnen, seine Sonnen fliegen"
>                       (Schiller, Beethoven)
> ============================================================
>
> _______________________________________________
> erlang-questions mailing list
> ://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list