Newbie question on arrays and indexing

Pierpaolo BERNARDI bernardp@REDACTED
Thu Mar 20 22:19:49 CET 2003


From: "Webb Sprague" <wwsprague@REDACTED>

> 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]).
{[5,7,9],not_initialized,{0,nil}}
12> A1 = array:set(A,[3,4,5],42).
{[5,7,9],not_initialized,{1,{[3,4,5],42,nil,nil}}}
13> array:ref(A1,[3,4,5]).
42
14> array:ref(A1,[1,1,1]).
not_initialized

Cheers
P.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: array.erl
Type: application/octet-stream
Size: 911 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20030320/fdfed731/attachment.obj>


More information about the erlang-questions mailing list