missing lists functions

Bengt Kleberg bengt.kleberg@REDACTED
Mon Mar 20 07:01:53 CET 2006


Tony Rogvall <tony@REDACTED>On 2006-03-18 11:09, Tony Rogvall wrote:
...deleted

i belive you might have missed a line in your example. imho this(*) 
makes the argument for keysearch_and_delete/3 slightly stronger.


> I tend to write code that looking like this:
> 
> Delete case:
>     case lists:keysearch(Key, Pos, List) of
>         false ->
>             recurse(State);
>         {value,{_,Value}} ->
(*) do_something(Value),
>             List1 = lists:keydelete(Key, Pos, List),
>             recurse(State#state { list = List1})
>     end.
> 
> "Reduce to"
> 
>     case lists:keysearch_and_delete(Key,Pos,List) of
>         false ->
>             recurse(State);
>         {value,{_,Value}, List1} ->
(*) do_something(Value),
>             recurse(State#state { list = List1 }
>     end.


bengt



More information about the erlang-questions mailing list