Creating an Array: Difference between revisions

From Rosetta Code
Content added Content deleted
mNo edit summary
m (Fix presentation of current page)
Line 10: Line 10:
==[[Visual Basic 2005.Net]]==
==[[Visual Basic 2005.Net]]==
Dim myArray as new ArrayList
Dim myArray as new ArrayList

Dim myArray2 as new ArrayList = { "Item1", "Item2" }
Dim myArray2 as new ArrayList = { "Item1", "Item2" }


Line 17: Line 16:
'''Libraries:''' [[None are needed]]
'''Libraries:''' [[None are needed]]


' $DYNAMIC
' $DYNAMIC
DIM SHARED myArray(-10 TO 10, 10 TO 30) AS STRING

DIM SHARED myArray(-10 TO 10, 10 TO 30) AS STRING
REDIM SHARED myArray(20, 20) AS STRING
REDIM SHARED myArray(20, 20) AS STRING
myArray(1,1) = "Item1";
myArray(1,1) = "Item1";


==[[Javascript]]==
==[[Javascript]]==
var myArray = new Array();
var myArray = new Array();
var myArray2 = new Array("Item1","Item2");

var myArray2 = new Array("Item1","Item2");


==[[3DS Max 8 - MaxScript]]==
==[[3DS Max 8 - MaxScript]]==
myArray = #()
myArray = #()
myArray2 = #("Item1", "Item2")

myArray2 = #("Item1", "Item2")




Line 50: Line 46:
'''Libraries:''' [[None are needed]]
'''Libraries:''' [[None are needed]]


@Array=(
@Array=(
[0,0,0,0,0,0],
[0,0,0,0,0,0],
[1,1,1,1,1,1],
[1,1,1,1,1,1],
[2,2,2,2,2,2],
[2,2,2,2,2,2],
[3,3,3,3,3,3]
[3,3,3,3,3,3]
);
);


#You would call the array by this code. This will call the 3rd 1 on the second list
#You would call the array by this code. This will call the 3rd 1 on the second list
print $Array[1][3];
print $Array[1][3];





Revision as of 18:03, 21 January 2007

Task
Creating an Array
You are encouraged to solve this task according to the task description, using any language you may know.

In this task, the goal is to create an array.

mIRC

Interpeter: mIRC Script Editor Libraries: mArray Snippet

alias creatmearray { .echo -a $array_create(MyArray, 5, 10) }

Visual Basic 2005.Net

Dim myArray as new ArrayList
Dim myArray2 as new ArrayList = { "Item1", "Item2" }

Quick Basic

Interpeter: QB 4.5 or PB 7.1 Libraries: None are needed

 ' $DYNAMIC
 DIM SHARED myArray(-10 TO 10, 10 TO 30) AS STRING
 REDIM SHARED myArray(20, 20) AS STRING
 myArray(1,1) = "Item1";

Javascript

 var myArray = new Array();
 var myArray2 = new Array("Item1","Item2");

3DS Max 8 - MaxScript

 myArray = #()
 myArray2 = #("Item1", "Item2")


Python

Interpeter: Python Libraries: None are needed

Array=[
       [0,0,0,0,0,0],
       [1,1,1,1,1,1],
       [2,2,2,2,2,2],
       [3,3,3,3,3,3]
      ]
#You would call the array by this code. This will call the 3rd 1 on the second list
Array[1][3]}

Perl

Interpeter: Perl Libraries: None are needed

@Array=(
        [0,0,0,0,0,0],
        [1,1,1,1,1,1],
        [2,2,2,2,2,2],
        [3,3,3,3,3,3]
      );
#You would call the array by this code. This will call the 3rd 1 on the second list
print $Array[1][3];


Template:Array operation