Getting the position of a list item

Tim Fletcher twoggle@REDACTED
Wed Dec 2 20:43:19 CET 2009


> Hmm, I fail to come up with a good usage scenario for wanting this. What are
> you needing the position of an item in a list for?

FWIW, here's something i wrote recently:

  base32_decode(Char) ->
    list_index(Char, base32_alphabet()).

  base32_alphabet() ->
    "0123456789bcdefghjkmnpqrstuvwxyz".


The corresponding encode function uses lists:nth/2.

Can't remember ever needing it before though (in erlang).


More information about the erlang-questions mailing list