Newbie question on arrays and indexing
Shawn Pearce
spearce@REDACTED
Thu Mar 20 19:30:12 CET 2003
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.
Webb Sprague <wwsprague@REDACTED> wrote:
> Hi Everybody,
>
> I am afraid this is just a stupid question, so if it is, please be nice
> and point me to some documentation... :)
>
> I am wondering what is the best way to handle indexing into a list or
> tuple. The issue at hand is that I want to play around with virtual
> clocks, as per Garg 2001, but all the algorithms are in terms of
> indexing using integers, like Matrix[3,4].
>
> Thanks
> Webb
>
--
Shawn.
... the flaw that makes perfection perfect.
More information about the erlang-questions
mailing list