Newbie question on arrays and indexing
Webb Sprague
wwsprague@REDACTED
Thu Mar 20 20:00:54 CET 2003
Shawn Pearce wrote:
>Try element/2:
>
>
>
>>T = {1, 2, 3, 4}.
>>
>>
>{1, 2, 3, 4}
>
>
>>element(1, T).
>>
>>
>1
>
>
>>element(3, T).
>>
>>
>3
>
>The first item in a tuple is index 1.
>I'm sure there's a function in lists to get the nth item of a list,
>I just haven't had the need to use that one.
>
This works, as does the following:
1>T = {{1, 2},{10, 20}}.
2>element(1, element(2,T)).
10
I was just wondering if there were a more graceful way to do it. I will
look into more variations on element.
Thanks
W
More information about the erlang-questions
mailing list