Cum se aplica o lista de functii pe o valoare ?

From HaskellWiki
Revision as of 22:36, 22 December 2007 by Ha$kell (talk | contribs)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Folosind vechea noastra cunostinta map si operatorul $ putem sa transferam o singura valoare (argument) unei liste de functii:


Ecemplul 1:

Prelude> map ($ 0)  [(1+),(2+),(23+)]
[1,2,23]

Ecemplul 2:

Prelude> map ($ 1) [(\x -> x+1) , (20+), (\y -> y *y) ]
[2,21,1]
Prelude> map ($ 2) [(\x -> x+1) , (20+), (\y -> y *y) ]
[3,22,4]
Prelude> map ($ 3) [(\x -> x+1) , (20+), (\y -> y *y) ]
[4,23,9]
Prelude>

Nota: Bineinteles ca functiile trebuie sa aiba acelasi tip.


<= Inapoi la pagina principala Ro/Haskell