how to hold lists

Yani Dzhurov yani.dzhurov@REDACTED
Fri May 12 12:57:55 CEST 2006


You are right :)

I need these lists to simulate some kind of enumarations.
I have two big enums /100 fields each/ which I want to split in 5 lists and
simulate them as enums in Erlang.
For instance
enum WeekDays {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday=20,
Sunday}
spilt them to lists
days1=[monday, tuesday, wednesday, thursday, friday]
And days2=[saturday, sunday].
So when I have 
WeekDay 1;
I can easily get it from the first list;
list:nth(1,days1).
If I have WeekDay 22;
lists:nth(22 - Offset, days2).

Also I need easily to get the value of WeekDays as ints.
So from thursday -> 3;
So I would get the index of thursday in the list days1.

This procedure looks pretty stupid in this example.
But when I have large enums and need to insert new values in it /{Monday,
Tuesday, Wednesday,SOME_OTHER_WEEK_DAY, Thursday, Friday, Saturday=20,
Sunday}/ it would be easy to maintain. 

If someone else has a better idea, pls advise me:)

10x,

yani


-----Original Message-----
From: owner-erlang-questions@REDACTED
[mailto:owner-erlang-questions@REDACTED] On Behalf Of Richard Carlsson
Sent: Friday, May 12, 2006 1:18 PM
To: Yani Dzhurov
Cc: erlang-questions@REDACTED
Subject: Re: how to hold lists

Yani Dzhurov wrote:
> I need to have some kind of global variables where to hold a couple of 
> lists. Also need them to process them pretty often by thousand of
processes.
> [...]
> I have about 5-6 lists with about 50 atoms each.
> 
> Is there any better approach?

I think that if you describe in more detail what these lists contain
and how you want to use them (e.g., what does "process them" mean,
more exactly?), people will be able to give you much better advice.

	/Richard






More information about the erlang-questions mailing list