removing last element from the list

Richard A. O'Keefe <>
Thu May 26 09:25:50 CEST 2005


Whoops.
	hi_rem({[X|L],R}) -> {X, {L,R}};
	hi_rem({[],[X|R]} -> hi_rem(reverse([X|R])).
	
should be

    hi_rem({[X|L],R}) -> {X, {L,R}};
    hi_rem({[],[X|R]} -> hi_rem({reverse([X|R]),[]}).

and
	lo_rem({L,[X|R]}) -> {X, {L,R}};
	lo_rem({[X|L],[]}) -> lo_rem(reverse([X|L])).

should be
	
    lo_rem({L,[X|R]}) -> {X, {L,R}};
    lo_rem({[X|L],[]}) -> lo_rem({[], reverse([X|L])}).

Untested code, OK?  I hope the idea was clear anyway.



More information about the erlang-questions mailing list