tags:

views:

595

answers:

2

These days I'm solving Project Euler problems in Erlang.

Since I'm a C++ programmer from the beginning, sometimes I really want to code using two dimensional arrays.

One of my idea is to use tuples and lists like this:

List=[{X,0}||X<-lists:seq(1,3)]
{1,0}
{2,0}
{3,0}

Is there nice way to implement multidimensional arrays in Erlang, please help me.

Thank you.

+1  A: 

See array module but for multidimensional access you have to write your own wrapper. If any of your dimension is short and access is mostly read you can use tuples and use erlang:element and erlang:setelement. Own wrapper is recommended anyway.

Hynek -Pichi- Vychodil
+1  A: 

Try array(actually dict) with {X, Y, Z} as a key. It's look like 3d array ;)

JLarky