Apply a callback to an array: Difference between revisions

From Rosetta Code
Content added Content deleted
mNo edit summary
(revert spam)
Line 1: Line 1:
{{task}}
[http://ruwier.125mb.com/kilkenny-cose/ kilkenny cose fare] [http://hoadmoni.125mb.com/styles/router-wireless/ router wireless dlink] [http://gitedy.125mb.com/blog/confalonieri/ confalonieri] [http://dacornel.125mb.com/data/maxtor-firewire.htm maxtor firewire hard disk] [http://nescogin.125mb.com/content/hola.htm hola] [http://woharwoo.angelfire.com/data/umberta-comi/ umberta comi venezia] [http://yonosoyyo.angelfire.com/directory/sexo-gay.htm sexo gay] [http://awihimmeru.angelfire.com/ven-a.htm ven a bailar iman] [http://ruwier.125mb.com/j-d/ j d dunn] [http://hahosmer.angelfire.com/html/incasso-piano.htm incasso piano cottura 90] [http://mamans.125mb.com/topic/erreway-sweet.htm erreway sweet baby mp3] [http://paryker.125mb.com/styles/barriere-acustiche/ barriere acustiche] [http://woharwoo.angelfire.com/data/bubblebabble/ bubblebabble] [http://stjollay.125mb.com/topic/lexmark-x/ lexmark x 1170] [http://kocarawf.125mb.com/blog/the-rasmus.htm the rasmus dead letters] [http://gistrate.angelfire.com/html/vendita-auto.htm vendita auto germania] [http://fikimber.125mb.com/lib/grow-life.htm grow life] [http://degaylor.125mb.com/last-minute/ last minute agosto 2004] [http://ruwier.125mb.com/stop-america/ stop america] [http://mamans.125mb.com/topic/fox-uomo.htm fox uomo viaggi] [http://dleslis.125mb.com/resources/dvd-uscita.htm dvd uscita dvii] [http://amarymuk.angelfire.com/html/scusa-gesu.htm scusa gesu ti do del tu] [http://nescogin.125mb.com/content/amanda-white.htm amanda white foto porno di amanda white] [http://wiellico.125mb.com/html/torture-iracheni.htm torture iracheni] [http://wiellico.125mb.com/html/ohe.htm ohe] [http://fikimber.125mb.com/lib/numerica.htm numerica 3] [http://dleslis.125mb.com/resources/ati-asus.htm ati asus x] [http://sawilson.125mb.com/data/esercito-italiano.htm esercito italiano rinvii] [http://fikimber.125mb.com/lib/nokia.htm nokia 3220] [http://fikimber.125mb.com/lib/i-sandali.htm i sandali] [http://kocarawf.125mb.com/blog/hidden-and.htm hidden and dangerous] [http://awihimmeru.angelfire.com/mappa-di.htm mappa di segrate] [http://degaylor.125mb.com/dois-a/ dois a um] [http://woharwoo.angelfire.com/data/www-samsungmobile/ www samsungmobile com] [http://wiellico.125mb.com/html/philips-televisore.htm philips televisore] [http://yonosoyyo.angelfire.com/directory/plextor-pxa.htm plextor px130a] [http://amarymuk.angelfire.com/html/descrizione.htm descrizione] [http://dacornel.125mb.com/data/stampante-samsung.htm stampante samsung laser ml 2010] [http://mamans.125mb.com/topic/tps-sat.htm tps sat] [http://degaylor.125mb.com/www-martina/ www martina stella it] [http://degaylor.125mb.com/romania-da/ romania da ru] [http://mamans.125mb.com/topic/simbiosi-mag.htm simbiosi mag] [http://slavfondmeister.angelfire.com/styles/lee-cabrera.htm lee cabrera] [http://bedrew.125mb.com/usb-driver.htm usb driver c650] [http://fikimber.125mb.com/lib/metallica-subsonica.htm metallica subsonica] [http://dacornel.125mb.com/data/web-tv.htm web tv sport] [http://bedrew.125mb.com/dragostea-din.htm dragostea din tei haiducii ozone] [http://mcclaise.angelfire.com/description/centri-commerciali/ centri commerciali provincia prato] [http://ruwier.125mb.com/cellulare-samsung/ cellulare samsung z510] [http://mcclaise.angelfire.com/description/foto-samantha/ foto samantha fantauzzi] [http://ruwier.125mb.com/jeff-buckley/ jeff buckley album grace] [http://awihimmeru.angelfire.com/lets-twist.htm lets twist again] [http://sawilson.125mb.com/data/last-minute.htm last minute montagna] [http://wiellico.125mb.com/html/passeggiata-nel.htm passeggiata nel bosco] [http://bedrew.125mb.com/balbastre.htm balbastre] [http://yonosoyyo.angelfire.com/directory/dvd-shrink.htm dvd shrink 2 3 ita] [http://sibeatri.angelfire.com/html/mp-garota/ mp3 garota de ipanema] [http://stjollay.125mb.com/topic/pastamatic-simac/ pastamatic simac] [http://mcclaise.angelfire.com/description/cellulari-simens/ cellulari simens nuovi modelli] [http://dacornel.125mb.com/data/www-allenatori.htm www allenatori fip it] [http://mamans.125mb.com/topic/u-s.htm u s robotic 56k] [http://mamans.125mb.com/topic/mia-martini.htm mia martini donna] [http://stjollay.125mb.com/topic/jameson-film/ jameson film dvd] [http://sewehner.125mb.com/articles/jeannette-porque/ jeannette porque te vas] [http://blhestrie.125mb.com/web/bologna-natal/ bologna natal] [http://yonosoyyo.angelfire.com/directory/mediaplayer-gb.htm mediaplayer 160gb] [http://hahosmer.angelfire.com/html/corpoforestale.htm corpoforestale] [http://gistrate.angelfire.com/html/perros.htm perros] [http://sibeatri.angelfire.com/html/carta-geografica/ carta geografica scandiano] [http://sewehner.125mb.com/articles/lago-digarda/ lago digarda] [http://dacornel.125mb.com/data/office-small.htm office small business edition] [http://dleslis.125mb.com/resources/gioco-creativi.htm gioco creativi bambino 2 4 anno] [http://mcclaise.angelfire.com/description/asus-pgdpro/ asus p5gd1pro] [http://vegrigsb.angelfire.com/resources/scotty-doesn.htm scotty doesn t know mp3] [http://degaylor.125mb.com/felina/ felina] [http://mamans.125mb.com/topic/austin-intrattenimento.htm austin intrattenimento] [http://paryker.125mb.com/styles/testi-villa/ testi villa ada] [http://mamans.125mb.com/topic/www-pinasco.htm www pinasco it] [http://hahosmer.angelfire.com/html/impermeabilizzazioni-a.htm impermeabilizzazioni a spruzzo] [http://awihimmeru.angelfire.com/provincia-caserta.htm provincia caserta] [http://nescogin.125mb.com/content/sonerie-polyphonique.htm sonerie polyphonique] [http://nescogin.125mb.com/content/adsl-tin.htm adsl tin] [http://ruwier.125mb.com/sobreviviendo/ sobreviviendo] [http://gistrate.angelfire.com/html/naya-breda.htm naya breda] [http://amarymuk.angelfire.com/html/mission-mi.htm mission m34i] [http://mcclaise.angelfire.com/description/gioco-dove/ gioco dove fai sesso] [http://mcclaise.angelfire.com/description/cambogia-/ cambogia la guerra dimenticata] [http://fikimber.125mb.com/lib/www-predators.htm www predators it] [http://spdinnie.angelfire.com/html/comune-di/ comune di incisa valdarno] [http://tibrown.125mb.com/description/sfondi-fantasy/ sfondi fantasy] [http://fikimber.125mb.com/lib/dvd-toto.htm dvd toto morto che parla] [http://ruwier.125mb.com/ragazze-in/ ragazze in costume da bagno] [http://mamans.125mb.com/topic/bistecchiera-grill.htm bistecchiera grill] [http://slavfondmeister.angelfire.com/styles/frigorifero-a.htm frigorifero a batteria] [http://sewehner.125mb.com/articles/rtl/ rtl 102 5] [http://paryker.125mb.com/styles/rai/ rai 3] [http://dleslis.125mb.com/resources/isabel-alliende.htm isabel alliende] [http://morudd.angelfire.com/web/trellian/ trellian] [http://sawilson.125mb.com/data/martina.htm martina] [http://stjollay.125mb.com/topic/borse-in/ borse in pelle] [http://blhestrie.125mb.com/web/nokia-tripla/ nokia tripla sim] [http://amarymuk.angelfire.com/html/procedura-civile.htm procedura civile] [http://amarymuk.angelfire.com/html/basi-dalla.htm basi dalla] [http://dleslis.125mb.com/resources/trapani-basket.htm trapani basket] [http://sawilson.125mb.com/data/paoli-vanoni.htm paoli vanoni insieme] [http://blhestrie.125mb.com/web/samsung-laser/ samsung laser colori] [http://bedrew.125mb.com/fantasma-dei.htm fantasma dei linea 77] [http://gitedy.125mb.com/blog/plastificatrici-a/ plastificatrici a3] [http://gistrate.angelfire.com/html/cozze-di.htm cozze di spot] [http://paryker.125mb.com/styles/val-canale/ val canale] [http://dacornel.125mb.com/data/questione-donore.htm questione donore] [http://sibeatri.angelfire.com/html/decoder-con/ decoder con hd] [http://sawilson.125mb.com/data/rikki-suteki.htm rikki suteki da ne] [http://stjollay.125mb.com/topic/video-pompini/ video pompini] [http://wiellico.125mb.com/html/tubo-policarbonato.htm tubo policarbonato] [http://awihimmeru.angelfire.com/seagate.htm seagate 7200 9] [http://wiellico.125mb.com/html/ww-rosso.htm ww rosso alice it] [http://tibrown.125mb.com/description/www-halloween/ www halloween it] [http://hoadmoni.125mb.com/styles/foto-di/ foto di silvia rocca] [http://bedrew.125mb.com/zucchelli.htm zucchelli] [http://amarymuk.angelfire.com/html/gomma-firenze.htm gomma firenze] [http://ruwier.125mb.com/wat-zou/ wat zou je doen] [http://blhestrie.125mb.com/web/seca-keys/ seca keys orbit] [http://sewehner.125mb.com/articles/yamaha-rxv/ yamaha rxv 757] [http://sawilson.125mb.com/data/buchi-pieni.htm buchi pieni] [http://gitedy.125mb.com/blog/home-theatre/ home theatre aiwa] [http://paryker.125mb.com/styles/california-dreams/ california dreams remix] [http://tibrown.125mb.com/description/que-bonito/ que bonito midi] [http://woharwoo.angelfire.com/data/salisburgo-shopping/ salisburgo shopping] [http://spdinnie.angelfire.com/html/benedetta-pavone/ benedetta pavone] [http://awihimmeru.angelfire.com/bachata-video.htm bachata video] [http://elernst.angelfire.com/articles/mania.htm mania] [http://kocarawf.125mb.com/blog/tomtom-per.htm tomtom per windows mobile 2003 se] [http://yonosoyyo.angelfire.com/directory/agriturismo-montebelluna.htm agriturismo montebelluna] [http://gitedy.125mb.com/blog/mercedes-a/ mercedes a 160] [http://paryker.125mb.com/styles/suoneria-polifonica/ suoneria polifonica sirena] [http://amarymuk.angelfire.com/html/porte-blindate.htm porte blindate roma] [http://sibeatri.angelfire.com/html/gestione-condominio/ gestione condominio] [http://bedrew.125mb.com/i-piu.htm i piu bei giochi] [http://slavfondmeister.angelfire.com/styles/gargolas.htm gargolas] [http://blhestrie.125mb.com/web/ray-charles/ ray charles 11settembre] [http://wiellico.125mb.com/html/navigatore-gps.htm navigatore gps per palm] [http://kocarawf.125mb.com/blog/schema-citofono.htm schema citofono urmet] [http://bedrew.125mb.com/victims.htm victims] [http://mamans.125mb.com/topic/samsonite-trekking.htm samsonite trekking 100] [http://tibrown.125mb.com/description/reflex-minolta/ reflex minolta digitale] [http://gitedy.125mb.com/blog/test-generici/ test generici] [http://champ-alnite.angelfire.com/muta-piscina.htm muta piscina] [http://hahosmer.angelfire.com/html/fujifilm-finepix.htm fujifilm finepix f402 fujifilm] [http://yarobiso.angelfire.com/text/game-bo.htm game bo y] [http://sewehner.125mb.com/articles/www-motorini/ www motorini zip sp it] [http://hoadmoni.125mb.com/styles/rory-gallagher/ rory gallagher] [http://stjollay.125mb.com/topic/pacolli/ pacolli] [http://blhestrie.125mb.com/web/daddy-yankee/ daddy yankee photos] [http://dacornel.125mb.com/data/campeggio-frigor.htm campeggio frigor] [http://slavfondmeister.angelfire.com/styles/wallpapers-of.htm wallpapers of emma watson] [http://hahosmer.angelfire.com/html/fujitsu-b.htm fujitsu b17] [http://gistrate.angelfire.com/html/per-qualche.htm per qualche dollaro in meno] [http://kocarawf.125mb.com/blog/microsoft-windows.htm microsoft windows media center] [http://yarobiso.angelfire.com/text/donna-cerca.htm donna cerca ragazzino] [http://fikimber.125mb.com/lib/ferrino-voyage.htm ferrino voyage] [http://dacornel.125mb.com/data/fiat-punto.htm fiat punto 1999] [http://degaylor.125mb.com/basile-alessandro/ basile alessandro] [http://stjollay.125mb.com/topic/porno-trailer/ porno trailer] [http://elernst.angelfire.com/articles/responsabile-di.htm responsabile di magazzino (regione veneto padova provincia)] [http://mamans.125mb.com/topic/borlanda.htm borlanda] [http://sewehner.125mb.com/articles/spe-perugia/ spe perugia] [http://sawilson.125mb.com/data/borsa-macchina.htm borsa macchina fotografica] [http://anethel.angelfire.com/bullets.htm bullets] [http://hahosmer.angelfire.com/html/sony-cyber.htm sony cyber shot t7] [http://dacornel.125mb.com/data/treviglio.htm treviglio] [http://vegrigsb.angelfire.com/resources/notaio-mosca.htm notaio mosca] [http://mcclaise.angelfire.com/description/centro-ufologico/ centro ufologico nazional] [http://dacornel.125mb.com/data/i-due.htm i due derelitti] [http://sawilson.125mb.com/data/mambwe.htm mambwe] [http://blhestrie.125mb.com/web/wolk-of/ wolk of life] [http://sawilson.125mb.com/data/windows-tra.htm windows tra aerei e nuvole] [http://sewehner.125mb.com/articles/freni-ciclismo/ freni ciclismo] [http://gitedy.125mb.com/blog/radio-portatile/ radio portatile sony digitale] [http://hahosmer.angelfire.com/html/gioco-cellulare.htm gioco cellulare samsung] [http://anethel.angelfire.com/b-b.htm b b a san gimignano] [http://kocarawf.125mb.com/blog/la-piccola.htm la piccola amica] [http://sibeatri.angelfire.com/html/csi-crime/ csi crime scene investigation stagione 2 vol 2] [http://mamans.125mb.com/topic/love-my.htm love my tender elvis presley] [http://kocarawf.125mb.com/blog/hard-disk.htm hard disk 7200 160] [http://sawilson.125mb.com/data/krzysztof-krawczyk.htm krzysztof krawczyk edyta] [http://degaylor.125mb.com/jelosil/ jelosil] [http://mamans.125mb.com/topic/nikon-coolpix.htm nikon coolpix] [http://vegrigsb.angelfire.com/resources/modem-advanced.htm modem advanced concrete] [http://fikimber.125mb.com/lib/just-for.htm just for you di lione richie] [http://mamans.125mb.com/topic/lesbiennes-mpeg.htm lesbiennes mpeg] [http://yonosoyyo.angelfire.com/directory/teresa-la.htm teresa la ladra] [http://dleslis.125mb.com/resources/desktop-vaio.htm desktop vaio] [http://hahosmer.angelfire.com/html/convertitore-audio.htm convertitore audio] [http://sawilson.125mb.com/data/testi-di.htm testi di canzoni tradotti] [http://degaylor.125mb.com/iraq-italiane/ iraq italiane rapite] [http://yonosoyyo.angelfire.com/directory/stampante-fiscali.htm stampante fiscali] [http://wiellico.125mb.com/html/www-angolo.htm www angolo tesi it] [http://wiellico.125mb.com/html/icc.htm icc] [http://paryker.125mb.com/styles/nec-nd/ nec nd 3520a] [http://cannotspell.ifrance.com/description/lib/amstrad-dvd/ amstrad dvd dvx] [http://stasiia.ifrance.com/img/styles/hugo-boss/ hugo boss baldessarini] [http://butanexlove.ifrance.com/lib/videos-de.htm videos de eminem] [http://gmkamm.ifrance.com/view/new/qtek-palmari.htm qtek palmari 9090] [http://heyclassylady.ifrance.com/html/kaaza.htm kaaza 2 4 3] [http://gmkamm.ifrance.com/view/new/carrozzeria-lombarda.htm carrozzeria lombarda] [http://last-shadow.ifrance.com/text/directory/www-twinset/ www twinset com] [http://rielethuil.ifrance.com/description/lib/club-border.htm club border collie] [http://sherryfraser03.ifrance.com/web/midi-pigro/ midi pigro] [http://sherryfraser03.ifrance.com/web/jenifer-anniston/ jenifer anniston] [http://rielethuil.ifrance.com/description/lib/vigilia-di.htm vigilia di nozze] [http://uo-ination.ifrance.com/lib/konica-minolta/ konica minolta dimage g500] [http://fishing-gro.ifrance.com/html/campionato-francese/ campionato francese serie b] [http://zonkismusik.ifrance.com/img/styles/acer-al.htm acer al1713] [http://rielethuil.ifrance.com/description/lib/canto-amore.htm canto amore e cha cha cha] [http://uo-ination.ifrance.com/lib/elenco-abbonati/ elenco abbonati telecom bari] [http://heyclassylady.ifrance.com/html/fans-de.htm fans de inu] [http://ryandrablya.ifrance.com/lib/dellamorte-dellamore.htm dellamorte dellamore film dvd] [http://uo-ination.ifrance.com/lib/cammeriere/ cammeriere] [http://pegasik.ifrance.com/html/pc-pixmania/ pc2100 pixmania] [http://lady-mosquito.ifrance.com/web/lds-net/ lds net] [http://stasiia.ifrance.com/img/styles/abbado-dvd/ abbado dvd] [http://pegasik.ifrance.com/html/just-i/ just i can t wait until tonight] [http://ryandrablya.ifrance.com/lib/museo-sociale.htm museo sociale como] [http://stasiia.ifrance.com/img/styles/acer-compiuter/ acer compiuter] [http://cannotspell.ifrance.com/description/lib/rs-va/ rs 800va] [http://fishing-gro.ifrance.com/html/trolley-per/ trolley per pc] [http://zonkismusik.ifrance.com/img/styles/vivo-in.htm vivo in un furgone] [http://la-seras.ifrance.com/library/html/quando-viene.htm quando viene dicembre] [http://lauashbu.ifrance.com/lib/obcecion/ obcecion] [http://rielethuil.ifrance.com/description/lib/www-chiocciolina.htm www chiocciolina it] [http://lady-mosquito.ifrance.com/web/notebook-acer/ notebook acer travelmate] [http://gmkamm.ifrance.com/view/new/savia-andina.htm savia andina] [http://pegasik.ifrance.com/html/rock-ascolta/ rock ascolta] [http://orbzine.ifrance.com/images/small/kali-filippino.htm kali filippino] [http://heyclassylady.ifrance.com/html/jobs-nursing.htm jobs nursing] [http://stasiia.ifrance.com/img/styles/codici-per/ codici per cellulari] [http://la-seras.ifrance.com/library/html/son-contento.htm son contento] [http://heyclassylady.ifrance.com/html/oro-.htm oro 90 srl] [http://uo-ination.ifrance.com/lib/smartmouse-programmatori/ smartmouse programmatori] [http://rielethuil.ifrance.com/description/lib/lalieno.htm lalieno] [http://cannotspell.ifrance.com/description/lib/punto-informatico/ punto informatico] [http://butanexlove.ifrance.com/lib/globetrotter.htm globetrotter] [http://lady-mosquito.ifrance.com/web/zenshu/ zenshu] [http://epireial-h.ifrance.com/topic/ministro.htm ministro] [http://lauashbu.ifrance.com/lib/caccia/ caccia] [http://zonkismusik.ifrance.com/img/styles/calcio-nazionale.htm calcio nazionale] [http://zonkismusik.ifrance.com/img/styles/isole-baleari.htm isole baleari maiorca minorca ibiza] [http://orbzine.ifrance.com/images/small/mission-impossi.htm mission impossi] [http://me4tateljnitsa.ifrance.com/data/ladja-o/ ladja o ledja] [http://cannotspell.ifrance.com/description/lib/giovanni-battista/ giovanni battista pergolesi livietta e tracollo la serva padrona] [http://stasiia.ifrance.com/img/styles/il-nucleo/ il nucleo essere romantico] [http://sherryfraser03.ifrance.com/web/ragazza-emon/ ragazza emon] [http://last-shadow.ifrance.com/text/directory/panasonic-lc/ panasonic lc 70] [http://orbzine.ifrance.com/images/small/tracy-spencer.htm tracy spencer] [http://fishing-gro.ifrance.com/html/porta-interna/ porta interna] [http://pegasik.ifrance.com/html/camera-buccinasco/ camera buccinasco] [http://lauashbu.ifrance.com/lib/la-psp/ la psp in una collezione fotografica] [http://epireial-h.ifrance.com/topic/condizionatore-multi.htm condizionatore multi daikin] [http://butanexlove.ifrance.com/lib/sexi-girl.htm sexi girl] [http://epireial-h.ifrance.com/topic/pay-aj.htm pay aj] [http://rielethuil.ifrance.com/description/lib/office-per.htm office per mac] [http://uo-ination.ifrance.com/lib/renault-laguna/ renault laguna 18] [http://lauashbu.ifrance.com/lib/libri-ginnastica/ libri ginnastica ritmica] [http://butanexlove.ifrance.com/lib/force.htm force 21] [http://last-shadow.ifrance.com/text/directory/bluetooth-print/ bluetooth print server] [http://last-shadow.ifrance.com/text/directory/ingolstadt/ ingolstadt] [http://ryandrablya.ifrance.com/lib/janine-turner.htm janine turner] [http://orbzine.ifrance.com/images/small/pirati-e.htm pirati e bucanieri] [http://me4tateljnitsa.ifrance.com/data/john-holmes/ john holmes] [http://stasiia.ifrance.com/img/styles/mario-cimarro/ mario cimarro] [http://uo-ination.ifrance.com/lib/brigante-se/ brigante se more] [http://cannotspell.ifrance.com/description/lib/psp-white/ psp white] [http://me4tateljnitsa.ifrance.com/data/supporto-a/ supporto a ventosa per palmari] [http://lauashbu.ifrance.com/lib/filmato-uccisione/ filmato uccisione quattrocchi] [http://bagrec.ifrance.com/lib/sheryl-crow.htm sheryl crow live from london] [http://ryandrablya.ifrance.com/lib/royal-park.htm royal park albatros club] [http://last-shadow.ifrance.com/text/directory/toner-gestetner/ toner gestetner] [http://sherryfraser03.ifrance.com/web/harry-e/ harry e tonto] [http://zonkismusik.ifrance.com/img/styles/easy-cd.htm easy cd creator free] [http://rielethuil.ifrance.com/description/lib/sport-scommessa.htm sport scommessa] [http://ryandrablya.ifrance.com/lib/samsung-d.htm samsung d410] [http://me4tateljnitsa.ifrance.com/data/gilbert-isole/ gilbert isole] [http://sherryfraser03.ifrance.com/web/deuxs/ deuxs] [http://pegasik.ifrance.com/html/blister/ blister] [http://me4tateljnitsa.ifrance.com/data/www-kalat/ www kalat net] [http://fishing-gro.ifrance.com/html/planet-phantom/ planet phantom california] [http://bagrec.ifrance.com/lib/maglieria-cavalli.htm maglieria cavalli] [http://me4tateljnitsa.ifrance.com/data/bit-the/ bit the wall] [http://rielethuil.ifrance.com/description/lib/izumo.htm izumo] [http://ryandrablya.ifrance.com/lib/via-isonzo.htm via isonzo grotta ferrata] [http://cannotspell.ifrance.com/description/lib/amd-/ amd 3000 sempron socket a] [http://heyclassylady.ifrance.com/html/e-lontano.htm e lontano] [http://la-seras.ifrance.com/library/html/arva.htm arva] [http://zonkismusik.ifrance.com/img/styles/myra-melford.htm myra melford] [http://epireial-h.ifrance.com/topic/memorie-ram.htm memorie ram ddr2] [http://last-shadow.ifrance.com/text/directory/ghibli/ ghibli] [http://epireial-h.ifrance.com/topic/accadde-in.htm accadde in paradiso] [http://gmkamm.ifrance.com/view/new/lacie.htm lacie 150] [http://zonkismusik.ifrance.com/img/styles/gioco-da.htm gioco da sparare] [http://fishing-gro.ifrance.com/html/step/ step] [http://stasiia.ifrance.com/img/styles/chat-a/ chat a fumetti] [http://bagrec.ifrance.com/lib/mature-and.htm mature and young gay] [http://fishing-gro.ifrance.com/html/bicicletta-mtb/ bicicletta mtb 24] [http://last-shadow.ifrance.com/text/directory/donne-famose/ donne famose nude] [http://lady-mosquito.ifrance.com/web/cerca-con/ cerca con libero] [http://uo-ination.ifrance.com/lib/passione-di/ passione di amazzoni] [http://heyclassylady.ifrance.com/html/scanner-c.htm scanner 7450c] [http://epireial-h.ifrance.com/topic/accessori-fotocamera.htm accessori fotocamera hp] [http://orbzine.ifrance.com/images/small/el.htm el 3] [http://butanexlove.ifrance.com/lib/pelle-donna.htm pelle donna] [http://fishing-gro.ifrance.com/html/palestra-roma/ palestra roma] [http://butanexlove.ifrance.com/lib/giugno.htm giugno 73] [http://la-seras.ifrance.com/library/html/bmw-d.htm bmw 530d eletta] [http://fishing-gro.ifrance.com/html/gazzetta-ufficiale/ gazzetta ufficiale della repubblica] [http://bagrec.ifrance.com/lib/code-dvd.htm code dvd] [http://uo-ination.ifrance.com/lib/portatile-/ portatile 17 professional] [http://epireial-h.ifrance.com/topic/info-su.htm info su virtua fighter 4 evolution] [http://bagrec.ifrance.com/lib/stampante-samsung.htm stampante samsung 510] [http://gmkamm.ifrance.com/view/new/mientes.htm mientes] [http://pegasik.ifrance.com/html/custonaci/ custonaci] [http://la-seras.ifrance.com/library/html/base-lessico.htm base (lessico)] [http://lauashbu.ifrance.com/lib/grimaud/ grimaud] [http://zonkismusik.ifrance.com/img/styles/morrowind-pc.htm morrowind pc] [http://lauashbu.ifrance.com/lib/proiettori-da/ proiettori da cinema] [http://pegasik.ifrance.com/html/il-comandante/ il comandante del flying moon] [http://me4tateljnitsa.ifrance.com/data/escort-gay/ escort gay maturi] [http://zonkismusik.ifrance.com/img/styles/testo-di.htm testo di minuetto] [http://heyclassylady.ifrance.com/html/graphire-tavolette.htm graphire tavolette grafiche] [http://stasiia.ifrance.com/img/styles/calzature-nike/ calzature nike donna inverno] [http://uo-ination.ifrance.com/lib/ragazzo-sesto/ ragazzo sesto fiorentino] [http://pegasik.ifrance.com/html/nikon-paraluce/ nikon paraluce] [http://heyclassylady.ifrance.com/html/si-demain.htm si demain bonnie tylor] [http://rielethuil.ifrance.com/description/lib/institutrice.htm institutrice] [http://epireial-h.ifrance.com/topic/www-hobby.htm www hobby caravan it] [http://orbzine.ifrance.com/images/small/runga.htm runga] [http://me4tateljnitsa.ifrance.com/data/robotica/ robotica] [http://lady-mosquito.ifrance.com/web/quang-namda/ quang namda nang] [http://cannotspell.ifrance.com/description/lib/peter-gabriel/ peter gabriel] [http://cannotspell.ifrance.com/description/lib/sapone-chitarra/ sapone chitarra] [http://la-seras.ifrance.com/library/html/elenco-scrutatori.htm elenco scrutatori 2006] [http://heyclassylady.ifrance.com/html/ma-bate.htm ma bate vantul ma bate] [http://orbzine.ifrance.com/images/small/ford-veneto.htm ford veneto] [http://last-shadow.ifrance.com/text/directory/russia/ russia] [http://butanexlove.ifrance.com/lib/liguria-rent.htm liguria rent] [http://fishing-gro.ifrance.com/html/www-marcopolo/ www marcopolo ion it] [http://stasiia.ifrance.com/img/styles/tris-scommessa/ tris scommessa] [http://orbzine.ifrance.com/images/small/informazioni-film.htm informazioni film troy] [http://orbzine.ifrance.com/images/small/robert-fisher.htm robert fisher] [http://lady-mosquito.ifrance.com/web/promozioni-hotel/ promozioni hotel rimini] [http://heyclassylady.ifrance.com/html/fiumi-di.htm fiumi di sborra] [http://lady-mosquito.ifrance.com/web/light-scribe/ light scribe masterizzatori dvd] [http://zonkismusik.ifrance.com/img/styles/tranquilli-domenico.htm tranquilli domenico] [http://lady-mosquito.ifrance.com/web/trust-dvd/ trust dvd wireless] [http://last-shadow.ifrance.com/text/directory/omosessuali-transex/ omosessuali transex sesso orge] [http://heyclassylady.ifrance.com/html/airasca.htm airasca] [http://stasiia.ifrance.com/img/styles/danny-kaye/ danny kaye] [http://gmkamm.ifrance.com/view/new/yuliya.htm yuliya] [http://bagrec.ifrance.com/lib/optio-s.htm optio s 30] [http://rielethuil.ifrance.com/description/lib/avensis-verso.htm avensis verso] [http://ryandrablya.ifrance.com/lib/legittima-offesa.htm legittima offesa] [http://rielethuil.ifrance.com/description/lib/britten.htm britten] [http://heyclassylady.ifrance.com/html/letto-a.htm letto a baldacchino] [http://stasiia.ifrance.com/img/styles/racalmuto/ racalmuto] [http://rielethuil.ifrance.com/description/lib/call-of.htm call of cthulhu] [http://la-seras.ifrance.com/library/html/il-tempo.htm il tempo passa] [http://la-seras.ifrance.com/library/html/top-calendar.htm top calendar beta 098] [http://cannotspell.ifrance.com/description/lib/fotos-maria/ fotos maria sharapova nua] [http://lady-mosquito.ifrance.com/web/buffy-tayler/ buffy tayler] [http://heyclassylady.ifrance.com/html/il-canto.htm il canto del gallo] [http://bagrec.ifrance.com/lib/risorsa-xbox.htm risorsa xbox] [http://fishing-gro.ifrance.com/html/ittica/ ittica 2000] [http://orbzine.ifrance.com/images/small/melodica-napoletana.htm melodica napoletana] [http://pegasik.ifrance.com/html/winxs-club/ winxs club] [http://epireial-h.ifrance.com/topic/toto-live.htm toto live in amsterdam 25th anniversary] [http://pegasik.ifrance.com/html/tv-dvd/ tv dvd 7] [http://heyclassylady.ifrance.com/html/enzo-gragnianiello.htm enzo gragnianiello] [http://ryandrablya.ifrance.com/lib/ps-kit.htm ps2 kit] [http://butanexlove.ifrance.com/lib/batterie-moto.htm batterie moto] [http://epireial-h.ifrance.com/topic/dissipatori-pentium.htm dissipatori pentium] [http://bagrec.ifrance.com/lib/motorola-companion.htm motorola companion] [http://sherryfraser03.ifrance.com/web/pc-mce/ pc mce] [http://fishing-gro.ifrance.com/html/biagio-antonacci/ biagio antonacci iris] [http://orbzine.ifrance.com/images/small/logitech-desktop.htm logitech desktop 700] [http://uo-ination.ifrance.com/lib/it-parade/ it parade] [http://lady-mosquito.ifrance.com/web/casa-affitto/ casa affitto mare calabria] [http://zonkismusik.ifrance.com/img/styles/portachiavi-con.htm portachiavi con zip] [http://cannotspell.ifrance.com/description/lib/giaca/ giaca] [http://ryandrablya.ifrance.com/lib/cassano-albergo.htm cassano albergo ma ri] [http://cannotspell.ifrance.com/description/lib/midis-usted/ midis usted] [http://heyclassylady.ifrance.com/html/studio-com.htm studio92 com] [http://last-shadow.ifrance.com/text/directory/scaricare-gioco/ scaricare gioco pc] [http://rielethuil.ifrance.com/description/lib/una-realta.htm una realta] [http://lauashbu.ifrance.com/lib/simpatica-canaglia/ simpatica canaglia] [http://bagrec.ifrance.com/lib/calcio-manageriale.htm calcio manageriale pc videogiochi] [http://la-seras.ifrance.com/library/html/venus-canzone.htm venus canzone] [http://la-seras.ifrance.com/library/html/otros-cantantes.htm otros cantantes del perreo] [http://stasiia.ifrance.com/img/styles/il-film/ il film ombre] [http://orbzine.ifrance.com/images/small/piscina-autoportante.htm piscina autoportante] [http://fishing-gro.ifrance.com/html/biellese-f/ biellese f c] {{task}}
== [[Ada]] ==
== [[Ada]] ==
[[Category:Ada]]
[[Category:Ada]]
'''Tested With:'''
'''Tested With:'''
* [[Gnat GPL 2005]]
* [[Gnat GPL 2005]]
** Amd-64bit-3500 -WinXP
** Amd-64bit-3500+-WinXP


with Ada.Text_Io;
with Ada.Text_Io;
Line 93: Line 93:
{
{
int i;
int i;
for(i = 0; i < len; i )
for(i = 0; i < len; i++)
{
{
callback(i, array[i]);
callback(i, array[i]);
Line 116: Line 116:
'''Platform:''' [[.NET]]
'''Platform:''' [[.NET]]


'''Language Version:''' 2.0
'''Language Version:''' 2.0+


'''Compiler:''' [[Visual C sharp|Visual C#]] 2005
'''Compiler:''' [[Visual C sharp|Visual C#]] 2005
Line 155: Line 155:
}
}


==[[C plus plus|C ]]==
==[[C plus plus|C++]]==
[[Category:C plus plus]]
[[Category:C plus plus]]
'''Compiler:''' [[GNU Compiler Collection]] 4.1.1
'''Compiler:''' [[GNU Compiler Collection]] 4.1.1
Line 171: Line 171:
int ary[]={1,2,3,4,5};
int ary[]={1,2,3,4,5};
//stl for_each
//stl for_each
std::for_each(ary,ary 5,print_square);
std::for_each(ary,ary+5,print_square);
return 0;
return 0;
}
}
Line 230: Line 230:
vector<int> ary(10);
vector<int> ary(10);
int i = 0;
int i = 0;
for_each(ary.begin(), ary.end(), _1 = var(i)); // init array
for_each(ary.begin(), ary.end(), _1 = ++var(i)); // init array
transform(ary.begin(), ary.end(), ostream_iterator<int>(cout, " "), _1 * _1); // square and output
transform(ary.begin(), ary.end(), ostream_iterator<int>(cout, " "), _1 * _1); // square and output


Line 267: Line 267:


(defvar *a* (vector 1 2 3))
(defvar *a* (vector 1 2 3))
(map-into *a* #'1 *a*)
(map-into *a* #'1+ *a*)


==[[E]]==
==[[E]]==
Line 301: Line 301:


: map ( addr n fn -- )
: map ( addr n fn -- )
-rot cells bounds do i @ over execute i ! cell loop ;
-rot cells bounds do i @ over execute i ! cell +loop ;


Example usage:
Example usage:


create data 1 , 2 , 3 , 4 , 5 ,
create data 1 , 2 , 3 , 4 , 5 ,
data 5 ' 1 map \ adds one to each element of data
data 5 ' 1+ map \ adds one to each element of data


==[[Fortran]]==
==[[Fortran]]==
Line 332: Line 332:


{square * . [id, id]}
{square * . [id, id]}
& square: <1,2,3,4,5>

== [[Haskell]] ==
[[Category:Haskell]]
'''Interpreter''' : [[GHC | GHCi]]

'''Compiler''' : [[GHC]]

let square x = x*x
let values = [1..10]
map square values

Using list comprehension to generate a list of the squared values
[square x | x <- values]

Using function composition to create a function that will print the squares of a list
let printSquares = putStr.unlines.map (show.square)
printSquares values


== [[IDL]] ==
[[Category:IDL]]

Hard to come up with an example that isn't completely contrived. IDL doesn't really distinguish between a scalar and an array; thus

b = a^3

will yield a scalar if a is scalar or a vector if a is a vector or an n-dimensional array is a is an n-dimensional array

== [[JavaScript]] ==
[[Category:JavaScript]]

Portable technique:

function map(a, func) {
for (var i in a)
a[i] = func(a[i]);
}
var a = [1, 2, 3, 4, 5];
map(a, function(v) { return v * v; });

With the [http://w3future.com/html/beyondJS/ BeyondJS] library:

var a = (1).to(10).collect(Math.pow.curry(undefined,2));

With Firefox 2.0:

function cube(num) {
return Math.pow(num, 3);
}
var numbers = [1, 2, 3, 4, 5];
//get results of calling cube on every element
var cubes1 = numbers.map(cube);
//display each result in a separate dialog
cubes1.forEach(alert);
//array comprehension
var cubes2 = [cube(n) for each (n in numbers)];
var cubes3 = [n * n * n for each (n in numbers)];

==[[Lua]]==
[[Category:Lua]]

Say we have an array:
myArray = {1, 2, 3, 4, 5}
A map function for this would be
map = function(f, data)
local result = {}
for k,v in ipairs(data) do
result[k] = f(v)
end
return result
end
Together with our array and and a square function this yields:
myFunc = function(x) return x*x end
print(unpack( map(myFunc, myArray) ))
--> 1 4 9 16 25
If you used pairs() instead of ipairs(), this would even work on a hash table in general.

== [[OCaml]] ==
[[Category:OCaml]]
This function is part of the standard library:

Array.map

Usage example:

let square x = x * x;;
let values = Array.init 10 ((+) 1);;
Array.map square values;;

==[[Perl]]==
[[Category:Perl]]

# create array
my @a = (1, 2, 3, 4, 5);

# create callback function
sub mycallback {
return 2 * shift;
}

# use array indexing
my $i;
for ($i = 0; $i < scalar @a; $i++) {
print "mycallback($a[$i]) = ", mycallback($a[$i]), "\n";
}

# using foreach
foreach my $x (@a) {
print "mycallback($x) = ", mycallback($x), "\n";
}

# using map (useful for transforming an array)
my @b = map mycallback($_), @a; # @b is now (2, 4, 6, 8, 10)

# and the same using an anonymous function
my @c = map { $_ * 2 } @a; # @c is now (2, 4, 6, 8, 10)

# use a callback stored in a variable
my $func = \&mycallback;
my @d = map &{$func}($_), @a; # @d is now (2, 4, 6, 8, 10)

==[[PHP]]==
[[Category:PHP]]

function cube($n)
{
return($n * $n * $n);
}
$a = array(1, 2, 3, 4, 5);
$b = array_map("cube", $a);
print_r($b);

== [[PL/SQL]] ==
[[Category:PL/SQL]]
'''Interpreter''' : Oracle compiler

set serveroutput on
declare
type myarray is table of number index by binary_integer;
x myarray;
i pls_integer;
begin
-- populate array
for i in 1..5 loop
x(i) := i;
end loop;
i :=0;
-- square array
loop
i := i + 1;
begin
x(i) := x(i)*x(i);
dbms_output.put_line(x(i));
exception
when no_data_found then exit;
end;
end loop;
end;
/

==[[Pop11]]==
[[Category:Pop11]]

;;; Define a procedure
define proc(x);
printf(x*x, '%p,');
enddefine;

;;; Create array
lvars ar = { 1 2 3 4 5};

;;; Apply procedure to array
appdata(ar, proc);

If one wants to create a new array consisting of transformed values
then procedure mapdata may be more convenient.


== [[Python]] ==
[[Category:Python]]
<pre>
def square(n):
return n * n
numbers = [1, 3, 5, 7]

squares1 = [square(n) for n in numbers] # list comprehension

squares2 = map(square, numbers) # discouraged nowadays

squares3 = [n * n for n in numbers] # no need for a function,
# anonymous or otherwise

isquares = (n * n for n in numbers) # iterator, lazy
</pre>

==[[Ruby]]==
[[Category:Ruby]]
# You could use a traditional "for i in arr" approach like below:
for i in [1,2,3,4,5] do
puts i**2
end

# Or you could the more preferred ruby way of an iterator (which is borrowed from SmallTalk)
[1,2,3,4,5].each{ |i| puts i**2 }

# To create a new array of each value squared
[1,2,3,4,5].map{ |i| i**2 }

==[[Scala]]==
[[Category:Scala]]
val l = List(1,2,3,4)
l.foreach {i => Console.println(i)}

Same for an array
val a = Array(1,2,3,4)
a.foreach {i => Console.println(i)}

// Or for an externally defined function
def doSomething(in: int) = {Console.println("Doing something with "+in)}
l.foreach(doSomething)

There is also a ''for'' syntax, which is internally rewritten to call foreach. A foreach method must be define on ''a''
for(val i <- a) Console.println(i)

It is also possible to apply a function on each item of an list to get a new list (same on array and most collections)
val squares = l.map{i => i * i} //returns List(1,4,9,16)

Or the equivalent ''for'' syntax, with the additional keyword ''yield'', map is called instead of foreach
val squares = for (val i <- l) yield i * i

== [[Scheme]] ==
[[Category:Scheme]]
(define (square n) (* n n))
(define x #(1 2 3 4 5))
(map square (vector->list x))


A single-line variation
(map (lambda (n) (* n n)) '(1 2 3 4 5))

For completeness, the <tt>map</tt> function (which is R5RS standard) can be coded as follows:
(define (map f L)
(if (null? L)
L
(cons (f (car L)) (map f (cdr L)))))

== [[Smalltalk]] ==
[[Category:Smalltalk]]
| anArray |
anArray = #( 1 2 3 4 5 )
anArray do: [ :x | Transcript nextPut: x * x ]

== [[Tcl]] ==
[[Category:Tcl]]

If I wanted to call "<tt>myfunc</tt>" on each element of <tt>dat</tt> and <tt>dat</tt> were a list:

foreach var $dat { myfunc $var }

if <tt>dat</tt> were an array, however:

foreach var [array names dat] { myfunc $dat($var) }

== [[Toka]] ==
[[Category:Toka]]

( array count function -- )
{
variable| array fn |
[ i 1- array @ ] is I
[ fn ! swap array ! [ I get-element fn @ invoke I put-element ] +iterate ]
} is map-array
( Build an array )
5 cells is-array a
10 0 a put-element
11 1 a put-element
12 2 a put-element
13 3 a put-element
14 4 a put-element
( Add 1 to each item in the array )
a 5 ` 1+ map-array

Revision as of 21:08, 30 August 2007

Task
Apply a callback to an array
You are encouraged to solve this task according to the task description, using any language you may know.

Ada

Tested With:

with Ada.Text_Io;
with Ada.Integer_text_IO;

procedure Call_Back_Example is
   -- Purpose: Apply a callback to an array
   -- Output: Prints the squares of an integer array to the console
  
   -- Define the callback procedure
   procedure Display(Location : Positive; Value : Integer) is
   begin
      Ada.Text_Io.Put("array(");
      Ada.Integer_Text_Io.Put(Item => Location, Width => 1);
      Ada.Text_Io.Put(") = ");
      Ada.Integer_Text_Io.Put(Item => Value * Value, Width => 1);
      Ada.Text_Io.New_Line;
   end Display;
  
   -- Define an access type matching the signature of the callback procedure
   type Call_Back_Access is access procedure(L : Positive; V : Integer);
  
   -- Define an unconstrained array type
   type Value_Array is array(Positive range <>) of Integer;
  
   -- Define the procedure performing the callback
   procedure Map(Values : Value_Array; Worker : Call_Back_Access) is
   begin
      for I in Values'range loop
         Worker(I, Values(I));
      end loop;
   end Map;
  
   -- Define and initialize the actual array
   Sample : Value_Array := (5,4,3,2,1);
  
begin
   Map(Sample, Display'access);   
end Call_Back_Example;

C

Tested With:

  • GCC 3.3.6
    • i686-pc-linux-gnu
  • GCC 3.4.6
    • i686-pc-linux-gnu
  • GCC 4.0.3
    • i686-pc-linux-gnu
  • GCC 4.1.1
    • i686-pc-linux-gnu
    • powerpc-unknown-linux-gnu
  • TCC 0.9.23
    • i686-pc-linux-gnu
  • ICC 9.1
    • i686-pc-linux-gnu

callback.h

 #ifndef __CALLBACK_H
 #define __CALLBACK_H
 /*
  * By declaring the function in a separate file, we allow
  * it to be used by other source files.
  *
  * It also stops ICC from complaining.
  *
  * If you don't want to use it outside of callback.c, this
  * file can be removed, provided the static keyword is prepended
  * to the definition.
  */
 void map(int* array, int len, void(*callback)(int,int));
 #endif

callback.c

 #include <stdio.h>
 #include "callback.h"
 /*
  * We don't need this function outside of this file, so
  * we declare it static.
  */
 static void callbackFunction(int location, int value)
 {
   printf("array[%d] = %d\n", location, value);
 } 
 void map(int* array, int len, void(*callback)(int,int))
 {
   int i;
   for(i = 0; i < len; i++)
   {
      callback(i, array[i]);
   }
 } 
 int main()
 {
   int array[] = { 1, 2, 3, 4 };
   map(array, 4, callbackFunction);
   return 0;
 }

Output

 array[0] = 1
 array[1] = 2
 array[2] = 3
 array[3] = 4

C#

Platform: .NET

Language Version: 2.0+

Compiler: Visual C# 2005

using System; 

static class Program
{
  // Purpose: Apply a callback (or anonymous method) to an Array
  // Output: Prints the squares of an int array to the console.
  // Compiler: Visual Studio 2005
  // Framework: .net 2
   
  [STAThread]
  public static void Main() 
  {
    int[] intArray = { 1, 2, 3, 4, 5 };

    // Using a callback,
    Console.WriteLine("Printing squares using a callback:");
    Array.ForEach<int>(intArray, PrintSquare);

    // or using an anonymous method:
    Console.WriteLine("Printing squares using an anonymous method:");
    Array.ForEach<int>
    (
      intArray,
      delegate(int value) 
      {
        Console.WriteLine(value * value);    
      });
  }

  public static void PrintSquare(int value) 
  { 
    Console.WriteLine(value * value);
  }
}

C++

Compiler: GNU Compiler Collection 4.1.1

Using c-style array

#include <iostream> //cout for printing
#include <algorithm> //for_each defined here
//create the function (print the square)
void print_square(int i) {
  std::cout << i*i << " ";
}
int main() {
  //create the array
  int ary[]={1,2,3,4,5};
  //stl for_each
  std::for_each(ary,ary+5,print_square);
  return 0;
}
//prints 1 4 9 16 25

Using std::vector

#include <iostream> //cout for printing
#include <algorithm> //for_each defined here
#include <vector> //stl vector class
//create the function (print the square)
void print_square(int i) {
  std::cout << i*i << " ";
}
int main() {
  //create the array
  std::vector<int> ary;
  ary.push_back(1);
  ary.push_back(2);
  ary.push_back(3);
  ary.push_back(4);
  ary.push_back(5);
  //stl for_each
  std::for_each(ary.begin(),ary.end(),print_square);
  return 0;
}
//prints 1 4 9 16 25

More tricky with binary function

#include <iostream> //cout for printing
#include <algorithm> //for_each defined here
#include <vector> //stl vector class
#include <functional> //bind and ptr_fun
//create a binary function (print any two arguments together)
template<class type1,class type2>
void print_juxtaposed(type1 x, type2 y) {
  std::cout << x << y;
}
int main() {
  //create the array
  std::vector<int> ary;
  ary.push_back(1);
  ary.push_back(2);
  ary.push_back(3);
  ary.push_back(4);
  ary.push_back(5);
  //stl for_each, using binder and adaptable unary function
  std::for_each(ary.begin(),ary.end(),std::bind2nd(std::ptr_fun(print_juxtaposed<int,std::string>),"x "));
  return 0;
}
//prints 1x 2x 3x 4x 5x

Using Boost.Lambda

 using namespace std;
 using namespace boost::lambda;
 vector<int> ary(10);
 int i = 0;
 for_each(ary.begin(), ary.end(), _1 = ++var(i)); // init array
 transform(ary.begin(), ary.end(), ostream_iterator<int>(cout, " "), _1 * _1); // square and output

Clean

Define a function and an initial (unboxed) array.

square x = x * x

values :: {#Int}
values = {x \\ x <- [1 .. 10]}

One can easily define a map for arrays, which is overloaded and works for all kinds of arrays (lazy, strict, unboxed).

mapArray f array = {f x \\ x <-: array}

Apply the function to the initial array (using a comprehension) and print result.

Start :: {#Int}
Start = mapArray square values

Common Lisp

Imperative: print 1, 2, 3, 4 and 5:

 (map nil #'print #(1 2 3 4 5))

Functional: collect squares into new vector that is returned:

 (defun square (x) (* x x))
 (map 'vector #'square #(1 2 3 4 5))

Destructive, like the Javascript example; add 1 to every slot of vector *a*:

 (defvar *a* (vector 1 2 3))
 (map-into *a* #'1+ *a*)

E

def array := [1,2,3,4,5]
def square(value) { 
    return value * value
}

Example of builtin iteration:

def callback(index, value) { 
    println(`Item $index is $value.`)
}
array.iterate(callback)

There is no builtin map function yet. the following is one of the ways one could be implemented, returning a plain list (which is usually an array in implementation).

def map(func, collection) {
    def output := [].diverge()
    for item in collection {
        output.push(func(item))
    }
    return output.snapshot()
}
println(map(square, array))

Forth

This is a word that will call a given function on each cell in an array.

: map ( addr n fn -- )
   -rot cells bounds do  i @ over execute i !  cell +loop ;

Example usage:

create data 1 , 2 , 3 , 4 , 5 ,
data 5 ' 1+ map  \ adds one to each element of data

Fortran

      program test
C
C--   Declare array:
      integer a(5)
C
C--   Fill it with Data
      data a /45,22,67,87,98/
C
C--   Do something with all elements (in this case: print their squares)
      do i=1,5
        print *,a(i)*a(i)
      end do
C
      end


FP

Interpreter : "fp"

 {square * . [id, id]}
 & square: <1,2,3,4,5>

Haskell

Interpreter : GHCi

Compiler : GHC

 let square x = x*x
 let values = [1..10]
 map square values

Using list comprehension to generate a list of the squared values

 [square x | x <- values]

Using function composition to create a function that will print the squares of a list

 let printSquares = putStr.unlines.map (show.square)
 printSquares values


IDL

Hard to come up with an example that isn't completely contrived. IDL doesn't really distinguish between a scalar and an array; thus

 b = a^3

will yield a scalar if a is scalar or a vector if a is a vector or an n-dimensional array is a is an n-dimensional array

JavaScript

Portable technique:

function map(a, func) {
  for (var i in a)
    a[i] = func(a[i]);
}

var a = [1, 2, 3, 4, 5];
map(a, function(v) { return v * v; });

With the BeyondJS library:

var a = (1).to(10).collect(Math.pow.curry(undefined,2));

With Firefox 2.0:

function cube(num) {
  return Math.pow(num, 3);
}

var numbers = [1, 2, 3, 4, 5];

//get results of calling cube on every element
var cubes1 = numbers.map(cube);

//display each result in a separate dialog
cubes1.forEach(alert);

//array comprehension
var cubes2 = [cube(n) for each (n in numbers)];
var cubes3 = [n * n * n for each (n in numbers)];

Lua

Say we have an array:

myArray = {1, 2, 3, 4, 5}

A map function for this would be

map = function(f, data)
   local result = {}
   for k,v in ipairs(data) do
      result[k] = f(v)
   end
   return result
end

Together with our array and and a square function this yields:

myFunc = function(x) return x*x end

print(unpack( map(myFunc, myArray) ))
--> 1   4   9   16  25

If you used pairs() instead of ipairs(), this would even work on a hash table in general.

OCaml

This function is part of the standard library:

 Array.map

Usage example:

 let square x = x * x;;
 let values = Array.init 10 ((+) 1);;
 Array.map square values;;

Perl

 # create array
 my @a = (1, 2, 3, 4, 5);
 # create callback function
 sub mycallback {
   return 2 * shift;
 }
 # use array indexing
 my $i;
 for ($i = 0; $i < scalar @a; $i++) {
   print "mycallback($a[$i]) = ", mycallback($a[$i]), "\n";
 }
 # using foreach
 foreach my $x (@a) {
   print "mycallback($x) = ", mycallback($x), "\n";
 }
 # using map (useful for transforming an array)
 my @b = map mycallback($_), @a;                # @b is now (2, 4, 6, 8, 10)
 # and the same using an anonymous function
 my @c = map { $_ * 2 } @a;                     # @c is now (2, 4, 6, 8, 10)
 # use a callback stored in a variable
 my $func = \&mycallback;
 my @d = map &{$func}($_), @a;                  # @d is now (2, 4, 6, 8, 10)

PHP

 function cube($n)
 {
    return($n * $n * $n);
 }
 
 $a = array(1, 2, 3, 4, 5);
 $b = array_map("cube", $a);
 print_r($b);

PL/SQL

Interpreter : Oracle compiler

 set serveroutput on
 declare
       type myarray is table of number index by binary_integer;
       x myarray;
       i pls_integer;
 begin
       -- populate array
       for i in 1..5 loop
               x(i) := i;
       end loop;
       i :=0;
 
       -- square array
       loop
               i := i + 1;
               begin
                       x(i) := x(i)*x(i);
                       dbms_output.put_line(x(i));
               exception 
                       when no_data_found then exit;
               end;
       end loop;
 
 end;
 /

Pop11

;;; Define a procedure
define proc(x);
    printf(x*x, '%p,');
enddefine;
;;; Create array
lvars ar = { 1 2 3 4 5};
;;; Apply procedure to array
appdata(ar, proc);

If one wants to create a new array consisting of transformed values then procedure mapdata may be more convenient.


Python

def square(n):
    return n * n
  
numbers = [1, 3, 5, 7]

squares1 = [square(n) for n in numbers] # list comprehension

squares2 = map(square, numbers)         # discouraged nowadays

squares3 = [n * n for n in numbers]     # no need for a function,
                                        # anonymous or otherwise

isquares = (n * n for n in numbers)     # iterator, lazy

Ruby

 # You could use a traditional "for i in arr" approach like below:
 for i in [1,2,3,4,5] do
    puts i**2
 end
 # Or you could  the more preferred ruby way of an iterator (which is borrowed from SmallTalk)
 [1,2,3,4,5].each{ |i| puts i**2 }  
 # To create a new array of each value squared
 [1,2,3,4,5].map{ |i| i**2 }

Scala

 val l = List(1,2,3,4)
 l.foreach {i => Console.println(i)}

Same for an array

 val a = Array(1,2,3,4)
 a.foreach {i => Console.println(i)}
 // Or for an externally defined function
 def doSomething(in: int) = {Console.println("Doing something with "+in)}
 l.foreach(doSomething)

There is also a for syntax, which is internally rewritten to call foreach. A foreach method must be define on a

for(val i <- a) Console.println(i)

It is also possible to apply a function on each item of an list to get a new list (same on array and most collections)

val squares = l.map{i => i * i} //returns  List(1,4,9,16)

Or the equivalent for syntax, with the additional keyword yield, map is called instead of foreach

val squares = for (val i <- l) yield i * i

Scheme

 (define (square n) (* n n))
 (define x #(1 2 3 4 5))
 (map square (vector->list x))


A single-line variation

 (map (lambda (n) (* n n)) '(1 2 3 4 5))

For completeness, the map function (which is R5RS standard) can be coded as follows:

 (define (map f L)
   (if (null? L)
       L
       (cons (f (car L)) (map f (cdr L)))))

Smalltalk

 | anArray |
 anArray = #( 1 2 3 4 5 )
 anArray do: [ :x | Transcript nextPut: x * x ]

Tcl

If I wanted to call "myfunc" on each element of dat and dat were a list:

 foreach var $dat { myfunc $var }

if dat were an array, however:

 foreach var [array names dat] { myfunc $dat($var) }

Toka

 ( array count function -- )
 {
   variable| array fn |
   [ i 1- array @ ] is I
   [ fn ! swap array ! [ I get-element fn @ invoke I put-element ] +iterate ]
 } is map-array
 
 ( Build an array )
 5 cells is-array a
 10 0 a put-element
 11 1 a put-element
 12 2 a put-element
 13 3 a put-element
 14 4 a put-element
 
 ( Add 1 to each item in the array )
 a 5 ` 1+ map-array