Using two(multi) dimensional array in Erlang

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?

Answers


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.


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


Need Your Help

How to find the offset of the Import Section in a PE32 file?

windows assembly executable pe

I have been trying to figure this out for hours but I cannot seem to get it. I have been trying to find the information in the Microsoft Documentation, but I'm overwhelmed by the amount of informat...

Bash scripting, checking for errors, logging

bash scripting shell

Here's one for the bash-fu wizards. No, actually, I'm just kidding, you'll all probably know this except for me..

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.