removing last element from the list

Vladimir Sekissov <>
Wed May 25 20:15:34 CEST 2005


Good day,

nm> are there any really fast ways to remove last element from list?
nm> 
nm> list size is 5-15 elements, but it's not known at compile time.
nm> 
nm> I need to implement something like FIFO, new elements inserted in list 
nm> push old elements out.

Look at _queue_ module in standard distribution.

Best Regards,
Vladimir Sekissov

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



More information about the erlang-questions mailing list