473,396 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Indexing an array with litterals

Hello,

I would like to index an "array" (semantic, not logic) with litterals in
a smart way. I could do as follow:

#define WHILE 0
#define IF 1
#define FOR 2
....

and then use WHILE IF FOR to index my array. But that is not really
smart.

Any idea? Thanks a lot for your help
-AJ
Nov 15 '05 #1
4 1014
Antoine Junod a écrit :
I would like to index an "array" (semantic, not logic) with litterals in
a smart way. I could do as follow:

#define WHILE 0
#define IF 1
#define FOR 2
...
or better

enum my_index
{
I_WHILE,
I_IF,
I_FOR,
I_NB
};
and then use WHILE IF FOR to index my array. But that is not really
smart.


What could be smarter ?

--
A+

Emmanuel Delahaye
Nov 15 '05 #2
> > I would like to index an "array" (semantic, not logic) with litterals in
a smart way. I could do as follow:
#define WHILE 0
#define IF 1
#define FOR 2
...


or better

enum my_index
{
I_WHILE,
I_IF,
I_FOR,
I_NB
};


That's really better. Thanks!

-AJ
Nov 15 '05 #3
Antoine Junod <to**@tots-ns.net> writes:
I would like to index an "array" (semantic, not logic) with litterals in
a smart way. I could do as follow:

#define WHILE 0
#define IF 1
#define FOR 2
...

and then use WHILE IF FOR to index my array. But that is not really
smart.


I have no idea what you mean by "semantic, not logic". Since you put
the word the word "array" in quotation marks, I'm guessing you don't
mean an array in the usual C sense, but I don't know what you do mean.

I suspect you're looking for an enumeration type.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '05 #4
> > I would like to index an "array" (semantic, not logic) with litterals in
a smart way. I could do as follow:

#define WHILE 0
#define IF 1
#define FOR 2
...

and then use WHILE IF FOR to index my array. But that is not really
smart.


I have no idea what you mean by "semantic, not logic". Since you put
the word the word "array" in quotation marks, I'm guessing you don't
mean an array in the usual C sense, but I don't know what you do mean.


Thanks for your answer Keith. Semantic means it was not a obligation for
me to use an array but I needes a structure that works a bit like an
array.
But the question was not well asked. I should preprare my questions a
bit better.

-AJ
Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Hilde Roth | last post by:
This may have been asked before but I can't find it. If I have a rectangular list of lists, say, l = ,,], is there a handy syntax for retrieving the ith item of every sublist? I know about for i...
6
by: Michael Drumheller | last post by:
(If you're not interested in NumArray, please skip this message.) I am new to NumArray and I wonder if someone can help me with array-indexing. Here's the basic situation: Given a rank-2 array...
10
by: Tamir Khason | last post by:
I have a pointer to array and I want to apply indexing to this Array so I have function (name it IntPrt Func) to go to certain member I can use (as C++) Func, but in C# I recieve an error "Cannot...
0
by: Chung Leong | last post by:
Here's a short tutorial on how to the OLE-DB extension to access Windows Indexing Service. Impress your office-mates with a powerful full-text search feature on your intranet. It's easier than you...
26
by: jacob navia | last post by:
Suppose an implementation where sizeof int == 4 sizeof void * == 8 sizeof long long == 8 When indexing an array array this would mean that arrays are limited to 2GB. To overcome this,
4
by: Grace Fang | last post by:
Hi, I am writing code to sort the columns according to the sum of each column. The dataset is huge (50k rows x 300k cols), so i need to read line by line and do the summation to avoid the...
4
by: Emin | last post by:
Dear Experts, How much slower is dict indexing vs. list indexing (or indexing into a numpy array)? I realize that looking up a value in a dict should be constant time, but does anyone have a...
4
by: Chiefy | last post by:
C# APP Basically i am trying to use indexing on an array that i have fed into a method as its parameter. Here is a simplified version of my code. public void Inputs(string path) { ...
3
by: Rüdiger Werner | last post by:
Hello! Out of curiosity and to learn a little bit about the numpy package i've tryed to implement a vectorised version of the 'Sieve of Zakiya'. While the code itself works fine it is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.