By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,812 Members | 856 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,812 IT Pros & Developers. It's quick & easy.

Extract data from arrays

P: n/a
Hi

This is probably fairly simple but I am newish at programming and was
wondering if someone can give me some advice on handling the following.

I have an array with a large number of elements in it. 0-9 are related
data, 10-19, 20-29 are related and so on. What is the best way of extracting
groups of elements from the array into another array where each element is
the related data or to extract say elements 0,1,5 from the first group,
10,11,15 from the second etc.

I have tried iterating through the array with if then statements but for a
large array this gets messy.

Any advice would be greatly appreciated.

Regards
Ian


Feb 8 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
If the elements are always 10, or some such number, that are related,
why not use a multi dimensional array instead?

T

ilr wrote:
Hi

This is probably fairly simple but I am newish at programming and was
wondering if someone can give me some advice on handling the following.

I have an array with a large number of elements in it. 0-9 are related
data, 10-19, 20-29 are related and so on. What is the best way of extracting
groups of elements from the array into another array where each element is
the related data or to extract say elements 0,1,5 from the first group,
10,11,15 from the second etc.

I have tried iterating through the array with if then statements but for a
large array this gets messy.

Any advice would be greatly appreciated.

Regards
Ian

Feb 8 '08 #2

P: n/a
Thanks for replying tomb.

The array is returned from a 3rd pary library so I don't really have much
choice in that respect.

"tomb" wrote:
If the elements are always 10, or some such number, that are related,
why not use a multi dimensional array instead?

T

ilr wrote:
Hi

This is probably fairly simple but I am newish at programming and was
wondering if someone can give me some advice on handling the following.

I have an array with a large number of elements in it. 0-9 are related
data, 10-19, 20-29 are related and so on. What is the best way of extracting
groups of elements from the array into another array where each element is
the related data or to extract say elements 0,1,5 from the first group,
10,11,15 from the second etc.

I have tried iterating through the array with if then statements but for a
large array this gets messy.

Any advice would be greatly appreciated.

Regards
Ian


Feb 8 '08 #3

P: n/a
Hi Lan

Sounds like this is an Algorithm question :)

I'm still not very sure about the exact result you want.

My understanding is you have a source array which may contains a large
sequence of elements. And a certain sub sequence of elements in the array
are of the same group(according to their index in array or their value?)
and you want to extract them out from the array and make the elements of
the same group together, correct?

As Tomb mentioned the "two-dim" array approach, I also think this is a good
idea if the interval or size of each group are fixed. You can create a
two-dimensional array in your code and copy all the elements from original
array into the two dimensional array.

Also, I think it would be helpful you provide more info such as some
example data(what's the original array and what you want to make them be
tranformed into and how you will use them after transformed). Thus, we can
look for some further ideas on this.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
\\
>From: =?Utf-8?B?aWxy?= <il*@noemail.noemail>
References: <F7**********************************@microsoft.co m>
<_T*******************@bignews7.bellsouth.net>
>Subject: Re: Extract data from arrays
Date: Thu, 7 Feb 2008 20:39:00 -0800
\
>
Thanks for replying tomb.

The array is returned from a 3rd pary library so I don't really have much
choice in that respect.

"tomb" wrote:
>If the elements are always 10, or some such number, that are related,
why not use a multi dimensional array instead?

T

ilr wrote:
Hi

This is probably fairly simple but I am newish at programming and was
wondering if someone can give me some advice on handling the following.

I have an array with a large number of elements in it. 0-9 are
related
data, 10-19, 20-29 are related and so on. What is the best way of
extracting
groups of elements from the array into another array where each
element is
the related data or to extract say elements 0,1,5 from the first
group,
10,11,15 from the second etc.

I have tried iterating through the array with if then statements but
for a
large array this gets messy.

Any advice would be greatly appreciated.

Regards
Ian

Feb 8 '08 #4

P: n/a
ilr,

This is so easy in VB

\\\
For i = X To 99 Step 10
'What you want to do
Next
///

Cor
Feb 9 '08 #5

P: n/a
Thanks Cor

I had considered step. Count gives me each 10th value. I was looking to
group the 10 values together.

Regards
ilr

"Cor Ligthert[MVP]" wrote:
ilr,

This is so easy in VB

\\\
For i = X To 99 Step 10
'What you want to do
Next
///

Cor
Feb 14 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.