Declare an array

From CodeCodex

Revision as of 21:44, 25 August 2007 by 192.72.124.10 (Talk)

copia guapa la rubrica di alessandra e costantino co angeli dei bassifondi custodia nikon coolpix lettore dvx philips camaleonti orbital all together etterbeek limbadi miauto com the challenge juegos en red epson stampante r1800 sotto i colpi dellaquila ochoa eugenio de butor michel foto tossa de mar traduzione di leave tivoli audiosongbook amsterdam attrazioni magico natale vaa pensiero lamda computer bologna seca keys c h natalia ot scanner hp scanjet 4370 palmone treo 650 bluetooth maxi tette giganti piante a torino monitor tft 15 1280x1024 impact stereo sony cybershot dscw17 parchis com telit gsm bluetooth stai con me stanotte geotherm video desnudo the classroom dynax 7d konica minolta kal 1000 os gran 30 bust webcam lan giustizialismo clio 12 16v besbol condizionatori da terra katia pedrotti gf4 nuda brother 1430 il signore e il mio pastore o sub eolo dio dei venti fihe pelose take me as i am philips astaire lc6281 spot contro bush puzzle clementoni 13200 quando finisce un amore vanderford video cerotto anticoncezionale nederlandse taal nike air max rosa calendario 2004 vanessa kelly giubbotto moto in pelle shinco 1700 girls sexy bei giochi camera cannes fiorello discografia candice michelle playboy fuji a340 finepix solo gratuiti carreras jose fulanito samsonite trolley 4 ruote patentino elbandolero occhiali sole www pn itnet it monitor lcd philips 170s6fg scheda del film a tu per tu lingerie sexy lebak configurazione v3i crescerai folgaria fuoco cottura per esterni i cinque penny torrecanne canon dcc 70 monitor touch chassis sony teleobiettivo www attori it power translator pro 9 mirage mp3 prodotti monteil lula 3d pci usb2 firewire lybra 2 4 ceviz lettore dvd combo divx yeah testo occhi da orientale kit vivavoce veicolare senza fili astrium here j go agin dvp900sa fiat punto 90 sporting jabra bt250v samsung tv lcd canon dv mv880x testi gianni fiorellino cartina germania the village cinema hard disk usb2 250gb infrarossi cuffie italia sardegna vacanze non dirmelo ci credo leggi sulle pertinenze firmware lg u8180 ministero istruzione it modem esterno postcard from french riviera rapper italiano bassi maestro frigorifero ariston mtaa nerd dani bananinha mobile per plasma agordo cremona batteria motorola v525 baia san felice rockinrio lisboa mia st john playboy 1999 canzoni fascisti fotografava egitto sharm apple ibook 12 software per videochat die lustige witwe registratore telefono nokia 3650 red octobre www manzone com www a c calcio cesena it un magico natale tatoo per fondoschiena diabolico diffusori 5 1 sony warum blur barry ryan midi lettore cd 300 id sw cd1 lee ryan blue filmati erotici gratis thomson 42pb220s4 congelatori incasso a mortasatrice edinburgh quei fantastici pazzi volanti dlink ant240801 sd mp3 radio melissa ford valvola di non ritorno www braid pitt it tenacious d stufe nordica tour cattura r zero nero wolfe sfida al cioccolato super smash lcd vga essi vivono escort a milano uploading hex key ragazzi 18 10 anni in posa una donna in cerca di brividi linksys wireless scandiuzzi dimm 256mb lego football mania mp3 creative zen micro se 5gb silvi marina lucia olga tovar porsche boxster argento volkswagen golf 2 0 tdi sport impianto hi fi panasonic rapporto 1991 sull economia del home cinema dvd hotel kennedy roma sum 41 at ip download msn plus sigla telegiornale canale 5 flinders (fiume) colonna sonora titanic frigoriferi combinati a due motori s3 trio64v2 dx sigma 18125 dc ricetta riso w w w invoglia it ristoranti parma hard disk sata2 This task should distinguish between languages that only allow array literals when declaring arrays (e.g. C, C , Java) and languages that allow array literals to be arbitrary expressions (e.g. OCaml, Lisp).

Implementations

Java

One dimension

String[] oneDimension;

or

String[] oneDimension[];

or

String oneDimension[];

Populating an array with values upon declaration:

String[] oneDimension = { "a","b","c" };

Declaring and creating an array of a set size:

String[] oneDimension = new String[10];
int[] oneDimension = new int[1000];

Two dimension

String[][] twoDimension;

or

String[][] twoDimension[][];

or

String twoDimension[][];

Populating an array with values upon declaration:

String[][] twoDimension = { {"1","2","3"}, {"4","5","6"}, {"7","8","9"} };

Common Lisp

* #(1 2 3)

#(1 2 3)


* #2A((1 2) (3 4))

#2A((1 2) (3 4))

OCaml

No need for type declarations in OCaml, thanks to type inference. OCaml has homogeneous arrays and provides array literals. For example:

# [|1; 2; 3|];;
- : int array = [|1; 2; 3|]

Note that array literals improve upon C-style (e.g. C and Java) array declarations because OCaml's array literals can be used anywhere (they are expressions) whereas the C-style is only valid on the right-hand side of an array declaration. For example, you can apply an array literal as a function argument directly in OCaml:

# Array.fold_left (   ) 0 [|1; 2; 3|];;
- : int = 6

Perl

<HIGHLIGHTSYNTAX language="perl"> my @arr = qw(1 2 3); my @two_dim = ([qw(1 2 3)], [qw(4 5 6)], [qw(7 8 9)]); </HIGHLIGHTSYNTAX>

Visual Basic (3-6)

One Dimensional

Fixed Length Array:

Dim Variable(5) as string

Variable Length Array:

Dim Variable() as string

Two Dimensional

Fixed by Fixed Length Array:

Dim Variable(5,2) as string

Fixed by Variable Length Array:

Dim Variable(5,) as string

Variable by Variable Length Array:

Dim Variable(,) as string