Newbie question on arrays and indexing

Pierpaolo BERNARDI <>
Thu Mar 20 22:19:49 CET 2003

From: "Webb Sprague" <>

> 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].

In addition to the other suggestions be sure to consider also
gb_trees, gb_sets and ets tables.

Find attached an example of an array interface built on gb_trees

11> A = array:make([5,7,9]).
12> A1 = array:set(A,[3,4,5],42).
13> array:ref(A1,[3,4,5]).
14> array:ref(A1,[1,1,1]).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: array.erl
Type: application/octet-stream
Size: 911 bytes
Desc: not available
URL: <>

More information about the erlang-questions mailing list