removing last element from the list

Serge Aleynikov <>
Wed May 25 20:13:46 CEST 2005


You can either use the stdlib's queue module or look at the user's 
contribution of double ended queues:

http://erlang.org/user.html#deque-1.0

Serge

Gaspar Chilingarov wrote:
> Hi all!
> 
> are there any really fast ways to remove last element from list?
> 
> list size is 5-15 elements, but it's not known at compile time.
> 
> I need to implement something like FIFO, new elements inserted in list 
> push old elements out.
> 
> now it looks line
> NewList = [ Elem | lists:sublist(List, N-1)]
> 
> which probably is not the best way.




More information about the erlang-questions mailing list