[erlang-questions] missing function

Serge Aleynikov <>
Tue Dec 23 13:39:07 CET 2008


There's been a discussion about very same subject in this thread:

http://www.erlang.org/pipermail/erlang-questions/2008-November/040189.html

I also hope OTP folks can include it in the lists module.

Serge

Robert Virding wrote:
> There are two points about your question:
> 
> 1. It is not strange that you cannot find such a function, it does not exist
> in the libraries. :-)
> 
> 2. It may also be strange that one does not exist, but so far no one has
> seen a need to add it to lists where it would belong.
> 
> Robert
> 
> 2008/12/23 Maxim Treskin <>
> 
>> Hello
>>
>> I can't find standard function which returns position of element in list
>> like:
>>
>> num(El, List) ->
>>     num(El, List, 1).
>>
>> num(_, [], _) -> {error, not_found};
>> num(El, [H|T], Acc) ->
>>     case H of
>>         El -> Acc;
>>         _ -> num(El, T, Acc+1)
>>     end.
>>
>> I think it strange. Can you clarify this point?
>>
>> Thank you.
>>
>> --
>> Maxim Treskin
>>
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list