[erlang-questions] Additions to lists module

Michael McDaniel erlangy@REDACTED
Thu Nov 27 00:52:15 CET 2008


 Everyone works on different kinds of problems and has their solutions.
 One immediate use I thought of follows.  

 Note that html_tokenise is from Joe Armstrong's www_tools-1.0 on trapexit.

 
 {ok, H} = http:request("http://somewebsite.com") ,
 Ht      = html_tokenise:string2toks( element(3, H) ) ,
 Pos     = list_position:pos( Hal, {tagStart,"title"} ) ,

 {_, Title} = lists:nth( Pos+1, Hal ).


 Likely there are other interesting items on a page for which I
 would have interest.


~Michael



On Wed, Nov 26, 2008 at 06:31:11PM -0500, Dave Smith wrote:
>    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 <[1]dave.smith.to@[2]gmail.com>
> 
>    2008/11/26 Mazen Harake <[3]mazen.harake@REDACTED>
> 
>      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)
> 
> References
> 
>    1. http://dave.smith.to/
>    2. http://gmail.com/
>    3. mailto:mazen.harake@REDACTED

> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 
Michael McDaniel
Portland, Oregon, USA
http://autosys.us




More information about the erlang-questions mailing list