[erlang-questions] Additions to lists module

Dave Smith <>
Thu Nov 27 00:31:11 CET 2008


But I do agree with you on the pos function. I don't think I would uses it.
Presumably one would want to do something with the position after retrieving
it, and this would probably mean using it in a function that traverses a
list a second time.

It would be more appropriate in a module like array.

2008/11/26 Dave Smith <>

>
> 2008/11/26 Mazen Harake <>
>
>> What is the idea behind pos?
>>
>> Curious because I have never been in a situation where I need to know
>> the actual position of an element since I always assume that the order
>> in a list is always undefined. Perhaps I missed something... do you have
>> a practical example?
>>
>> /M
>>
>>
> I'm not following. Lists are ordered and in many cases order is
> meaningful.  Otherwise you would never have reason to reverse a list.
>
> There are many functions in the lists module where the result is dependant
> on the lists order, and there is precedence for functions like foldlwhile;
> examples (takewhile/2, dropwhile/2, splitwith/2)
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20081126/f60b5e28/attachment.html>


More information about the erlang-questions mailing list