Adding Arrays to Arrays 
Author Message
 Adding Arrays to Arrays

Is there an elegant way to use aadd() to combine two multi
dimensional arrays so that the contents of each column are
appended?  

dir1 := directory("*.prg")
dir2 := directory("*.txt")
dir3 := {}

// this does _NOT_ produce the result I want in dir3
// the resulting array has 3 dimensions

aadd(dir3,dir1)
aadd(dir3,dir2)

What I want is an array containing directory information for *.prg
and *.txt files.  

The solution should also work for two arrays created with
dbstruct().

Please e-mail me any suggestions.

Thanks,

Michael Jenkins
Control Tech Consulting Inc.
(905) 790-1507
http://www.*-*-*.com/ ~jenkinsm



Mon, 01 Mar 1999 03:00:00 GMT  
 Adding Arrays to Arrays



Quote:
13:55:51 GMT writes:

:>
:>Is there an elegant way to use aadd() to combine two multi
:>dimensional arrays so that the contents of each column are
:>appended?  
:>
:>dir1 := directory("*.prg")
:>dir2 := directory("*.txt")
:>dir3 := {}
:>
:>// this does _NOT_ produce the result I want in dir3
:>// the resulting array has 3 dimensions
:>
:>aadd(dir3,dir1)
:>aadd(dir3,dir2)
:>
:>What I want is an array containing directory information for *.prg
:>and *.txt files.  
:>
:>The solution should also work for two arrays created with
:>dbstruct().
:>
:>Please e-mail me any suggestions.
:>
:>Thanks,
:>
:>
:>
:>Michael Jenkins
:>Control Tech Consulting Inc.
:>(905) 790-1507
:>http://www.interlog.com/~jenkinsm

aDir3 := AClone(dir1)

FOR nX := 1 To Len(dir2)
    AAdd(aDir3, dir2[nX])
NEXT nX

Gary Crossno



Mon, 01 Mar 1999 03:00:00 GMT  
 Adding Arrays to Arrays

Quote:

> Is there an elegant way to use aadd() to combine two multi
> dimensional arrays so that the contents of each column are
> appended?

> dir1 := directory("*.prg")
> dir2 := directory("*.txt")
> dir3 := {}

> // this does _NOT_ produce the result I want in dir3
> // the resulting array has 3 dimensions

> aadd(dir3,dir1)
> aadd(dir3,dir2)

> What I want is an array containing directory information for *.prg
> and *.txt files.

> The solution should also work for two arrays created with
> dbstruct().

AEVAL( DIR1, { |E| AADD( DIR3, E } )
AEVAL( DIR2, { |E| AADD( DIR3, E } )

--
Andi Jahja
Jakarta, INDONESIA
http://www.geocities.com/SiliconValley/4231/index.html



Tue, 02 Mar 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Problem with with Array of U8 to Array of Array of Boolean

2. convert 2d array to 1d array without using shift registers and build array

3. Arrays: Build array in multiple for loops or replace array elements

4. Multidimensional array vs. array of array

5. Question about array ops on arrays of types of arrays of ...(ack)

6. adjustable-array-p, adjust-array and array-destruction

7. Adding shell arrays (is it possible?)

8. adding all possible combinations of numbers in an array

9. Adding records from an array

10. strings adding zero's to arrays

11. How do I read lines of Text from Text File and add them to Array

12. Adding an element in an array of cluster of 2 elements

 

 
Powered by phpBB® Forum Software