[erlang-questions] 2D Map Arrays
Mon Sep 11 21:37:34 CEST 2006
--- Richard Carlsson <> wrote:
> Jeff Crane wrote:
> > Can anyone post example usage for the Array
> > implementation?
> > I'd like to see proper usage.
> On the other hand, there _is_ a heap of unit testing
> inside the module, with plenty of usage examples.
I dont see it.
N0 = ?LEAFSIZE,
N01 = N0+1,
N1 = ?NODESIZE*N0,
N11 = N1+1,
N2 = ?NODESIZE*N1,
?_assert(new() == new(0)),
?_assert(new(0) == new(0,undefined)),
?_assert(0 == array:size(new())),
?_assert(undefined == default(new())),
?_assert(new(10) == new(10,undefined)),
?_assert(17 == array:size(new(17))),
?_assert(4711 == default(new(0,4711)))
This doesn't have any real meaning to me. I'm sure
it's because I don't have enough erlang experience to
understand what that's supposed to do, but it's nearly
incomprehensible compared to
> Did you not see the html documentation
Which I had not seen.
> > How do I push a value into the array?
> Use the 'set' function. I will probably add some
> extra functions such as 'append' later.
> > Does it dynamically resize?
MyNewArr = array:new(0,0),
MyBiggerArr = array:set(1,4,MyNewArr),
That's an example I can understand. Arrays are
identified by the tuples returned from array:new
All functions are essentially read-only functions, but
you cannot reassign variables so this requires
reassignment to new Atoms as the array is processed.
I now know more about how to use the Array module for
temporary data storage than I know about ets (
- that's a lot of digging for not much in the way of
Yes, I'm not amazingly good at learning how to read
and use erlang modules, but I am happy to be the
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
More information about the erlang-questions