Creating an Array: Difference between revisions

Blanked page since people can't / don't read
mNo edit summary
(Blanked page since people can't / don't read)
 
(181 intermediate revisions by 50 users not shown)
Line 1:
{{DeprecatedTask}}
[http://lamcgie.t35.com/web/nokia-.htm nokia 6630 titanium grey] [http://ouquaite.freeweb7.com/img/styles/ufo-shado/ ufo shado] [http://coarmago.freeweb7.com/library/html/carnielli-ultraskiff.htm carnielli ultraskiff] [http://jututor.125mb.com/lib/park-hyatt/ park hyatt hotel] [http://rimarsh.t35.com/images/small/tuscany-country.htm tuscany country house] [http://trocterli.t35.com/img/styles/clan-of/ clan of sicilians] [http://fergus-mac.somee.com/description/lib/excel-recovery/ excel recovery] [http://betheresa.t35.com/text/directory/tvc-plasma/ tvc plasma] [http://lamcgie.t35.com/web/giuseppe-toaldo.htm giuseppe toaldo] [http://am-i-bird.somee.com/img/styles/dipinti-su.htm dipinti su lenzuola] [http://nairoz.somee.com/img/styles/torcia-maglite/ torcia mag-lite] [http://madavid.t35.com/html/video-bosa/ video bosa] [http://madavid.t35.com/html/ibm-a/ ibm a] [http://jututor.125mb.com/lib/home-cinema/ home cinema scott] [http://flheddina.t35.com/web/fasciatoio-legno/ fasciatoio legno] [http://lamcgie.125mb.com/html/software-crea.htm software crea presentazioni] [http://dj-deus.somee.com/lib/fragole.htm fragole] [http://dabeutle.t35.com/content/view/fujitsusiemens-d.htm fujitsu-siemens d1845] [http://viemalin.freeweb7.com/resources/articles/porta-sezionale.htm porta sezionale] [http://peter-land.somee.com/images/small/lavatrice-candy.htm lavatrice candy cty] [http://lamcgie.125mb.com/html/sintoampli-onkyo.htm sintoampli onkyo] [http://ouquaite.freeweb7.com/img/styles/exit/ exit] [http://lensman.somee.com/html/mortuary-academy/ mortuary academy] [http://rimarsh.t35.com/images/small/in-compagnia.htm in compagnia dei lupi] [http://brrezab.freeweb7.com/img/styles/conoscere-il.htm conoscere il proprio peso forma] [http://trocterli.t35.com/img/styles/codec-indeo/ codec indeo down load gratis] [http://fawarfo.freeweb7.com/topic/face-.htm face 2 face] [http://dabeutle.t35.com/content/view/sabrina-ghio.htm sabrina ghio amici] [http://dj-deus.somee.com/lib/ballini.htm ballini] [http://thegoogly.somee.com/view/new/donne-incinte.htm donne incinte gratis] [http://quotes-girl.somee.com/content/view/dead-can/ dead can dance ascension] [http://lamcgie.125mb.com/html/britney-spears.htm britney spears video musicali] [http://ouquaite.freeweb7.com/img/styles/modem-senza/ modem senza fili] [http://betheresa.t35.com/text/directory/salvator-mundi/ salvator mundi] [http://trocterli.t35.com/img/styles/se-tu/ se tu non fossi qui] [http://rihelm.125mb.com/img/styles/saldatrice-moderna/ saldatrice moderna] [http://coarmago.freeweb7.com/library/html/hard-disk.htm hard disk esterni maxtor 200gb] [http://nationavce.somee.com/library/html/fotocopiatrice-canon/ fotocopiatrice canon] [http://brrezab.freeweb7.com/img/styles/gianna-dimarco.htm gianna dimarco] [http://thegoogly.somee.com/view/new/face-sitting.htm face sitting fisting] [http://brrezab.freeweb7.com/img/styles/colate-continue.htm colate continue] [http://lamcgie.125mb.com/html/pc-mediacenter.htm pc mediacenter] [http://davelovesyou.somee.com/library/html/miele-w/ miele w 200] [http://jututor.125mb.com/lib/sexe-sexe/ sexe sexe sexe anal grasse] [http://coarmago.freeweb7.com/library/html/pinne-omer.htm pinne omer sub] [http://nairoz.somee.com/img/styles/modem-adsl/ modem adsl wireless 3com] [http://dj-deus.somee.com/lib/glossop.htm glossop] [http://thegoogly.somee.com/view/new/muore-anna.htm muore anna tatangelo] [http://nairoz.somee.com/img/styles/mappe-fantasy/ mappe fantasy] [http://jedillar.125mb.com/resources/articles/immagini-grtuite/ immagini grtuite nudi] [http://fawarfo.freeweb7.com/topic/culle-chicco.htm culle chicco] [http://dj-deus.somee.com/lib/forca-furtado.htm forca furtado] [http://flheddina.t35.com/web/paps-n/ paps n skar luna] [http://am-i-bird.somee.com/img/styles/versace.htm versace 4018] [http://itgurney.t35.com/view/new/batterie-samsung/ batterie samsung a300] [http://dj-deus.somee.com/lib/premier-manager.htm premier manager 3] [http://lamcgie.t35.com/web/renault-clio.htm renault clio 1 4] [http://lamcgie.t35.com/web/testo-di.htm testo di kings of convenience] [http://trocterli.t35.com/img/styles/annunci-di/ annunci di coppia] [http://yourorus.somee.com/data/succulente-piante.htm succulente piante] [http://rimarsh.t35.com/images/small/dieta-settimanale.htm dieta settimanale] [http://nairoz.somee.com/img/styles/pm/ pm670] [http://am-i-bird.somee.com/img/styles/palazzo-lanza.htm palazzo lanza] [http://quotes-girl.somee.com/content/view/pelle-giubbino/ pelle giubbino donna abbigliamento] [http://betheresa.t35.com/text/directory/hard-disk/ hard disk 1000 gb] [http://lakitsmi.freeweb7.com/web/dvd-amstrad/ dvd amstrad dx3070] [http://nationavce.somee.com/library/html/fuck-eamon/ fuck eamon testo] [http://flheddina.t35.com/web/elenco-finanziarie/ elenco finanziarie brindisi] [http://rimarsh.t35.com/images/small/volkswagen-.htm volkswagen golf 1.9 td 3p.] [http://quotes-girl.somee.com/content/view/formula/ formula 101] [http://davelovesyou.somee.com/library/html/ornella-muti/ ornella muti nude] [http://jedillar.125mb.com/resources/articles/wireless-networking/ wireless networking] [http://rimarsh.t35.com/images/small/yaesu-vx.htm yaesu vx 7] [http://jututor.125mb.com/lib/www-itcg/ www itcg sansovino it] [http://yourorus.somee.com/data/the-cure.htm the cure. out of the woods] [http://luallard.t35.com/html/amd-venice/ amd venice] [http://jedillar.125mb.com/resources/articles/solo-anale/ solo anale] [http://lamcgie.125mb.com/html/mp-mp.htm mp3 mp120] [http://nationavce.somee.com/library/html/cristalli-sognanti/ cristalli sognanti] [http://lamcgie.125mb.com/html/giochi-non.htm giochi non troppa paura] [http://lamcgie.125mb.com/html/l-incidente.htm l incidente di alba parietti] [http://luallard.t35.com/html/fornaciari-luigi/ fornaciari, luigi] [http://am-i-bird.somee.com/img/styles/cercasi-moglie.htm cercasi moglie] [http://yourorus.somee.com/data/hawai-big.htm hawai big island hotel] [http://lamcgie.125mb.com/html/mouse-blue.htm mouse blue tooth] [http://luallard.t35.com/html/lettori-dvd/ lettori dvd sacd] [http://itgurney.t35.com/view/new/auerbach-erich/ auerbach, erich] [http://dj-deus.somee.com/lib/xmen.htm xmen2] [http://brrezab.freeweb7.com/img/styles/fax-ricoh.htm fax ricoh 570] [http://thegoogly.somee.com/view/new/cristi-shake.htm cristi shake] [http://fawarfo.freeweb7.com/topic/poda-de.htm poda de manzanos] [http://betheresa.t35.com/text/directory/tadeusz-kantor/ tadeusz kantor] [http://itgurney.t35.com/view/new/traduzione-trik/ traduzione trik me] [http://lensman.somee.com/html/o-frame/ o frame] [http://de-der.somee.com/library/html/sony-dvpns.htm sony dvp-ns 32] [http://nationavce.somee.com/library/html/hp-officejet/ hp officejet multifunzione] [http://nationavce.somee.com/library/html/ristrutturazioni-quanti/ ristrutturazioni quanti anni si puo sca] [http://coarmago.freeweb7.com/library/html/tyrone-power.htm tyrone power] [http://quotes-girl.somee.com/content/view/mp-sony/ mp3 sony fm] [http://trocterli.t35.com/img/styles/pete-doherty/ pete doherty] [http://ouquaite.freeweb7.com/img/styles/microsoft-windows/ microsoft windows 2003 licenza] [http://dj-deus.somee.com/lib/portatile-videoproiettori.htm portatile videoproiettori benq] [http://trocterli.t35.com/img/styles/giochi-di/ giochi di taxi] [http://flheddina.t35.com/web/novita-online/ novita online] [http://nationavce.somee.com/library/html/novecento-mp/ novecento mp3] [http://thegoogly.somee.com/view/new/bed-and.htm bed and brekfast] [http://coarmago.freeweb7.com/library/html/lee-sabi.htm lee sabi] [http://luallard.t35.com/html/notte-bianca/ notte bianca roma] [http://ouquaite.freeweb7.com/img/styles/produttori-sauna/ produttori sauna] [http://jututor.125mb.com/lib/due-come/ due come noi. vol. 04] [http://rihelm.125mb.com/img/styles/ibm-alimentatore/ ibm alimentatore] [http://lamcgie.125mb.com/html/di-sole.htm di sole d azzurro] [http://davelovesyou.somee.com/library/html/squirters/ squirters] [http://davelovesyou.somee.com/library/html/camedia-c/ camedia c 370 zoom olympus] [http://am-i-bird.somee.com/img/styles/colonna-sonora.htm colonna sonora dirty dancing] [http://ouquaite.freeweb7.com/img/styles/gay-cgat/ gay cgat] [http://rimarsh.t35.com/images/small/scarpa-tiger.htm scarpa tiger] [http://trocterli.t35.com/img/styles/ccdb/ ccdb 69] [http://fergus-mac.somee.com/description/lib/eosmark-ii/ eos-mark ii] [http://jututor.125mb.com/lib/sahrawi/ sahrawi] [http://lamcgie.125mb.com/html/gif-animata.htm gif animata animale] [http://fawarfo.freeweb7.com/topic/video-de.htm video de monica adaro] [http://kiboukni.125mb.com/web/tu-parad/ tu parad com] [http://kiboukni.125mb.com/web/corso-di/ corso di l i s] [http://am-i-bird.somee.com/img/styles/evanescence-hello.htm evanescence hello] [http://de-der.somee.com/library/html/cliniche-toscana.htm cliniche toscana] [http://nationavce.somee.com/library/html/calendari-sesso/ calendari sesso ebony] [http://dj-deus.somee.com/lib/msw.htm msw] [http://ouquaite.freeweb7.com/img/styles/hdrhce-sony/ hdr-hc1e sony] [http://fawarfo.freeweb7.com/topic/ragazze-incinte.htm ragazze incinte porche] [http://fergus-mac.somee.com/description/lib/metropoli/ metropoli] [http://fergus-mac.somee.com/description/lib/rimax-usbeat/ rimax usbeat 303] [http://thegoogly.somee.com/view/new/ritorno.htm ritorno] [http://nationavce.somee.com/library/html/asus-opteron/ asus opteron] [http://kiboukni.125mb.com/web/secondo-piatto/ secondo piatto] [http://luallard.t35.com/html/satsw/ satsw] [http://jedillar.125mb.com/resources/articles/macchine-fotografiche/ macchine fotografiche digitali canon] [http://betheresa.t35.com/text/directory/foto-di/ foto di animali per schermo computer] [http://kiboukni.125mb.com/web/web-design/ web design rovigo] [http://davelovesyou.somee.com/library/html/piedi-a/ piedi a confronto] [http://trocterli.t35.com/img/styles/prezioso-despre/ prezioso despre tine] [http://brrezab.freeweb7.com/img/styles/sony-cybershot.htm sony cyber-shot dsc-h1] [http://dj-deus.somee.com/lib/audi-noleggio.htm audi noleggio a lungo termine] [http://trocterli.t35.com/img/styles/www-elisabetta/ www elisabetta canalis e bobo vieri it t] [http://am-i-bird.somee.com/img/styles/tv-samsung.htm tv samsung 17] [http://itgurney.t35.com/view/new/porno-video/ porno video download] [http://itgurney.t35.com/view/new/crime-party/ crime party] [http://jututor.125mb.com/lib/torta-carota/ torta carota] [http://nairoz.somee.com/img/styles/lavoro-ostuni/ lavoro ostuni] [http://fawarfo.freeweb7.com/topic/affirmations.htm affirmations] [http://davelovesyou.somee.com/library/html/dogrib/ dogrib] [http://nationavce.somee.com/library/html/un-pugno/ un pugno di fango] [http://madavid.t35.com/html/ml/ ml 1710] [http://rimarsh.t35.com/images/small/il-sottomarino.htm il sottomarino] [http://trocterli.t35.com/img/styles/calvin-klein/ calvin klein intimo donna] [http://flheddina.t35.com/web/videos-pornografico/ videos pornografico gartis] [http://dabeutle.t35.com/content/view/lagos-regione.htm lagos (regione della nigeria)] [http://lamcgie.125mb.com/html/gare-e.htm gare e appalti] [http://itgurney.t35.com/view/new/offerta-regali/ offerta regali friuli venezia giulia] [http://thegoogly.somee.com/view/new/copioni-natalizi.htm copioni natalizi] [http://kiboukni.125mb.com/web/jusy-feel/ jusy feel better] [http://trocterli.t35.com/img/styles/nokia-umts/ nokia umts cellulari] [http://ouquaite.freeweb7.com/img/styles/cronotek/ cronotek] [http://fergus-mac.somee.com/description/lib/web-cam/ web cam 640 480] [http://thegoogly.somee.com/view/new/ragazzo-corsico.htm ragazzo corsico] [http://flheddina.t35.com/web/chicco-/ chicco - s3 top] [http://dabeutle.t35.com/content/view/four-to.htm four to the flor] [http://madavid.t35.com/html/orologio-sportivi/ orologio sportivi] [http://coarmago.freeweb7.com/library/html/flea.htm flea] [http://jedillar.125mb.com/resources/articles/sony-televisore/ sony televisore] [http://lamcgie.125mb.com/html/videi-gratis.htm videi gratis porno] [http://lamcgie.125mb.com/html/piccolo-grande.htm piccolo grande amore baglioni] [http://lamcgie.125mb.com/html/pesca-artesanal.htm pesca artesanal] [http://peter-land.somee.com/images/small/astronotus.htm astronotus] [http://kiboukni.125mb.com/web/geografia-economica/ geografia economica] [http://luallard.t35.com/html/canon-powershot/ canon powershot s 2] [http://viemalin.freeweb7.com/resources/articles/ethere.htm ethere] [http://kiboukni.125mb.com/web/www-strathfield/ www strathfield com au] [http://am-i-bird.somee.com/img/styles/m-ti.htm m91 ti] [http://kiboukni.125mb.com/web/suspicion/ suspicion] [http://dj-deus.somee.com/lib/mail-tv.htm mail tv satellite] [http://de-der.somee.com/library/html/athlon-.htm athlon 64 san diego] [http://trocterli.t35.com/img/styles/silent-boost/ silent boost xp] [http://luallard.t35.com/html/cliccalavoro/ cliccalavoro] [http://itgurney.t35.com/view/new/claudia-mori/ claudia mori] [http://davelovesyou.somee.com/library/html/alloggio-italia/ alloggio italia] [http://coarmago.freeweb7.com/library/html/kar-guns.htm kar guns n roses] [http://fergus-mac.somee.com/description/lib/custodia-subaquea/ custodia subaquea] [http://fawarfo.freeweb7.com/topic/toshiba-pentium.htm toshiba pentium m 750] [http://lensman.somee.com/html/magnex/ magnex 300] [http://lamcgie.125mb.com/html/raffreddamento-hd.htm raffreddamento hd] [http://lakitsmi.freeweb7.com/web/il-mistero/ il mistero della pietra azzurra] [http://de-der.somee.com/library/html/acer-ferrari.htm acer ferrari 4002 wlmi] [http://madavid.t35.com/html/calendario-bellucci/ calendario bellucci 2005] [http://lakitsmi.freeweb7.com/web/toto-di/ toto di trans nude e orge] [http://luallard.t35.com/html/ford-focus/ ford focus km zero] [http://trocterli.t35.com/img/styles/baby-control/ baby control chicco telecamera] [http://rimarsh.t35.com/images/small/lunario-del.htm lunario del paradiso] [http://rimarsh.t35.com/images/small/telefono-caldo.htm telefono caldo] [http://davelovesyou.somee.com/library/html/win-sms/ win sms 2 4] {{task}}
'''Please do not add new code, and merge existing code to the [[Arrays]] task.'''
This task is about [[numeric arrays]]. For '''hashes''' or '''associative arrays''', please see [[Creating an Associative Array]].
 
This task is about numerically-indexed arrays. For '''hashes''' or '''associative arrays''', please see [[Creating an Associative Array]].
In this task, the goal is to create an [[array]]. Mention if the [[array base]] begins at a number other than zero.
 
In this task, the goal is to create an [[array]]. Mention if the [[array base]] begins at a number other than zero.
==[[ActionScript]]==
In addition, demonstrate how to initialize an array variable with data.
[[Category:ActionScript]]
// ActionScript arrays are zero-based
//
// creates an empty array
var arr1:Array = new Array();
// creates an array with 3 numerical values
var arr2:Array = new Array(1,2,3);
//
// or just use the shorthand
var u:Array = [];
var v:Array = [1,2,3];
 
==[[Ada]]==
[[Category:Ada]]
'''Compiler:''' GCC 4.1.2
 
Ada array indices may begin at any value, not just 0 or 1
type Arr is array (Integer range <>) of Integer;
Uninitialized : Arr (1 .. 10);
Initialized_1 : Arr (1 .. 20) := (others => 1);
Initialized_2 : Arr := (1 .. 30 => 2);
Const : constant Arr := (1 .. 10 => 1, 11 .. 20 => 2, 21 | 22 => 3);
Centered : Arr (-50..50) := (0 => 1, Others => 0);
Ada arrays may be indexed by enumerated types, which are discrete non-numeric types
type Days is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
type Activities is (Work, Fish);
type Daily_Activities is array(Days) of Activities;
This_Week : Daily_Activities := (Mon..Fri => Work, Others => Fish);
 
==[[AppleScript]]==
[[Category:AppleScript]]
AppleScript supports "arrays" as "lists," and they are not limited by a single type.
set array1 to {}
set array2 to {1, 2, 3, 4, "hello", "world"}
 
==[[BASIC]]==
[[Category:BASIC]]
'''Interpeter:''' [[QuickBasic]] 4.5, PB 7.1
 
REM Force index to start at 1..n
OPTION BASE 1
 
REM Force index to start at 0..n
OPTION BASE 0
 
REM Specify that the array is dynamic and not static
'$DYNAMIC
DIM SHARED myArray(-10 TO 10, 10 TO 30) AS STRING
REDIM SHARED myArray(20, 20) AS STRING
myArray(1,1) = "Item1"
myArray(1,2) = "Item2"
 
==[[C]]==
[[Category:C]]
'''Compiler:''' GCC, MSVC, BCC, Watcom
 
'''Libraries:''' Standard
Dynamic
#include <stdlib.h> /* for malloc */
#include <string.h> /* for memset */
int n = 10 * sizeof(int);
int *myArray = (int*)malloc(n);
if(myArray != NULL)
{
memset(myArray, 0, n);
myArray[0] = 1;
myArray[1] = 2;
free(myArray);
myArray = NULL;
}
 
Static
 
int myArray2[10] = { 1, 2, 0}; /* 3..9 := 0 */
 
==[[C plus plus|C ]]==
[[Category:C plus plus]]
'''Compiler:''' [[GCC]], [[Visual C plus plus|Visual C ]], [[BCC]], [[Watcom]]
 
 
Using dynamically-allocated memory:
const int n = 10;
int* myArray = new int[n];
if(myArray != NULL)
{
myArray[0] = 1;
myArray[1] = 2;
delete[] myArray;
myArray = NULL;
}
 
Using fixed memory:
int myArray2[10] = { 1, 2, 0}; /* 3..9 := 0 */
 
'''Libraries:''' [[STL]]
// STL
std::vector<int> myArray3(10);
myArray3.push_back(1);
myArray3.push_back(2);
 
'''Libraries:''' [[Qt]]
// Qt
QVector<int> myArray4(10);
myArray4.push_back(1);
myArray4.push_back(2);
 
'''Libraries:''' [[Microsoft Foundation Classes]]
// MFC
CArray<int,int> myArray5(10);
myArray5.Add(1);
myArray5.Add(2);
 
==[[C sharp|C#]]==
[[Category:C sharp]]
Example of array of 10 int types:
 
int[] numbers = new int[10];
 
Example of array of 3 string types:
 
string[] words = { "these", "are", "arrays" };
 
You can also declare the size of the array and initialize the values at the same time:
 
int[] more_numbers = new int[3]{ 21, 14 ,63 };
 
 
For Multi-Deminsional arrays you declare them the same except for a comma in the type declaration.
 
The following creates a 3x2 int matrix
int[,] number_matrix = new int[3,2];
 
As with the previous examples you can also initialize the values of the array, the only difference being each row in the matrix must be enclosed in its own braces.
 
string[,] string_matrix = { {"I","swam"}, {"in","the"}, {"freezing","water"} };
 
or
 
string[,] funny_matrix = new string[2,2]{ {"clowns", "are"} , {"not", "funny"} };
 
==[[Clean]]==
[[Category:Clean]]
Array denotations are overloaded in Clean, therefore we explicitly specify the types. There are lazy, strict, and unboxed array.
===Lazy array===
Create a lazy array of strings using an array denotation.
array :: {String}
array = {"Hello", "World"}
Create a lazy array of floating point values by sharing a single element.
array :: {Real}
array = createArray 10 3.1415
Create a lazy array of integers using an array (and also a list) comprehension.
array :: {Int}
array = {x \\ x <- [1 .. 10]}
===Strict array===
Create a strict array of integers.
array :: {!Int}
array = {x \\ x <- [1 .. 10]}
===Unboxed array===
Create an unboxed array of characters, also known as <tt>String</tt>.
array :: {#Char}
array = {x \\ x <- ['a' .. 'z']}
 
==[[ColdFusion]]==
[[Category:ColdFusion]]
Creates a one-dimensional Array
<cfset arr1 = ArrayNew(1)>
Creates a two-dimensional Array in CFScript
<cfscript>
arr2 = ArrayNew(2);
</cfscript>
''ColdFusion Arrays are '''NOT''' zero-based, they begin at index '''1'''''
 
==[[Common Lisp]]==
[[Category:Common Lisp]]
Creates a one-dimensional array of length 10.
(make-array 10)
Creates a two-dimensional array with dimensions 10x20.
(make-array '(10 20))
<tt>make-array</tt> may be called with a number of optional arguments.
(make-array 4 :element-type 'fixnum :initial-contents '(1 2 3 4) :adjustable t)
==[[D]]==
[[Category:D]]
'''Compiler:''' [[DMD]],[[GDC]]
 
// dynamic array
int[] numbers = new int[5];
// static array
int[5] = [0,1,2,3,4];
 
==[[Forth]]==
[[Category:Forth]]
 
Forth has a variety of ways to allocate arrays of data, though it has no built-in array handling words, favoring pointer manipulation.
 
Static array of 200 cells, uninitialized:
 
create MyArray 200 cells allot
here MyArray - cell / constant MyArraySize
 
Static array containing the numbers 1 to 5
 
create MyArray 1 , 2 , 3 , 4 , 5 ,
here MyArray - cell / constant MyArraySize
 
Dynamic array allocation:
0 value MyArray
200 cells allocate throw to MyArray
 
Dynamic array free:
MyArray free throw
0 to MyArray
 
==[[Fortran]]==
[[Category:Fortran]]
 
Default case:
 
integer a(10)
 
this will have ten elements. Counting starts at 1. If a zero-based array is needed, declare like this:
 
integer a(0:9)
 
this mechanism can be extended to any numerical indices, and allowed number of dimensions (and of course to other data types than integers). For example
 
real*8 (25:29,12)
 
will be an two-dimensional, 5x12-array of 8-byte floats, where the first dimension can be addressed numerically as 25, 26, 27, 28 or 29 (and the second dimension as 1 .. 12).
 
 
==[[IDL]]==
[[Category:IDL]]
 
IDL doesn't really distinguish between scalars and arrays - the same operations that can create the one can <i>usually</i> create the other as well.
 
a = 3
help,a
A INT = 3
print,a^2
9
 
a = [3,5,8,7]
help,a
A INT = Array[4]
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]]==
[[Category:Perl]]
'''Interpreter:''' [[Perl]] 5
 
my @empty;
my @empty_too = ();
 
my @populated = ('This', 'That', 'And', 'The', 'Other');
print $populated[2];
# And
my $aref = ['This', 'That', 'And', 'The', 'Other'];
print aref->[2];
# And
 
# having to quote like that really sucks, and that's why we got syntactic sugar
my @wakey_wakey = qw(coffee sugar cream);
push @wakey_wakey, 'spoon';
# add spoon to right-hand side
my $cutlery = pop @wakey_wakey;
# remove spoon
unshift @wakey_wakey, 'cup';
# add cup to left-hand side
my $container = shift @wakey_wakey;
# remove cup
 
my @multi_dimensional = (
[0, 1, 2, 3],
[qw(a b c d e f g)],
[qw(! $ %
 
==[[Toka]]==
[[Category:Toka]]
Toka allows creation of an array using is-array. Access to the elements is done using
get-element, put-element, get-char-element, and put-char-element functions. You can
not initialize the values automatically using the core array functions.
 
100 cells is-array foo
100 chars is-array bar
10,333

edits