Anonymous user
Creating an Array: Difference between revisions
m
Put Java--OCaml into the right alphabetical order.
(-> Fortran) |
m (Put Java--OCaml into the right alphabetical order.) |
||
Line 210:
print,a^2
9 25 64 49
==[[Java]]==▼
[[Category:Java]]▼
For example for an array of 10 int values:▼
int[] intArray = new int[10];▼
Creating an array of Strings:▼
String[] s = {"hello" , "World" };▼
==[[JavaScript]]==▼
[[Category:JavaScript]]▼
var myArray = new Array();▼
var myArray2 = new Array("Item1","Item2");▼
var myArray3 = ["Item1", "Item2"];▼
==[[MAXScript]]==▼
[[Category:MAXScript]]▼
'''Interpreter:''' [[3D Studio Max]] 8▼
myArray = #()▼
myArray2 = #("Item1", "Item2")▼
==[[mIRC Scripting Language]]==▼
[[Category:mIRC Scripting Language]]▼
'''Interpeter:''' mIRC Script Editor▼
'''Libraries:''' [[mArray Snippet]]▼
alias creatmearray { .echo -a $array_create(MyArray, 5, 10) }▼
==[[OCaml]]==▼
[[Category:OCaml]]▼
Using an array literal:▼
let array = [| 1; 2; 3; 4; 5 |];;▼
To create an array of five elements with the value 0:▼
let num_items = 5 and initial_value = 0;;▼
let array = Array.make num_items initial_value▼
To create an array with contents defined by passing each index to a callback (in this example, the array is set to the squares of the numbers 0 through 4):▼
let callback index = index * index;;▼
let array = Array.init 5 callback▼
==[[Perl]]==
Line 323 ⟶ 368:
(1 :: 2 :: 3 :: 4 :: 5 :: Nil).toArray
▲==[[Java]]==
▲[[Category:Java]]
▲For example for an array of 10 int values:
▲ int[] intArray = new int[10];
▲Creating an array of Strings:
▲ String[] s = {"hello" , "World" };
▲==[[JavaScript]]==
▲[[Category:JavaScript]]
▲ var myArray = new Array();
▲ var myArray2 = new Array("Item1","Item2");
▲ var myArray3 = ["Item1", "Item2"];
▲==[[MAXScript]]==
▲[[Category:MAXScript]]
▲'''Interpreter:''' [[3D Studio Max]] 8
▲ myArray = #()
▲ myArray2 = #("Item1", "Item2")
▲==[[mIRC Scripting Language]]==
▲[[Category:mIRC Scripting Language]]
▲'''Interpeter:''' mIRC Script Editor
▲'''Libraries:''' [[mArray Snippet]]
▲ alias creatmearray { .echo -a $array_create(MyArray, 5, 10) }
▲==[[OCaml]]==
▲[[Category:OCaml]]
▲Using an array literal:
▲ let array = [| 1; 2; 3; 4; 5 |];;
▲To create an array of five elements with the value 0:
▲ let num_items = 5 and initial_value = 0;;
▲ let array = Array.make num_items initial_value
▲To create an array with contents defined by passing each index to a callback (in this example, the array is set to the squares of the numbers 0 through 4):
▲ let callback index = index * index;;
▲ let array = Array.init 5 callback
==[[Smalltalk]]==
|