Difference between revisions of "Cum se aplica o lista de functii pe o valoare ?"
Jump to navigation
Jump to search
m |
|||
Line 3: | Line 3: | ||
---- |
---- |
||
− | ''' |
+ | '''Exemplul 1:''' |
<haskell> |
<haskell> |
||
Prelude> map ($ 0) [(1+),(2+),(23+)] |
Prelude> map ($ 0) [(1+),(2+),(23+)] |
||
Line 11: | Line 11: | ||
---- |
---- |
||
− | ''' |
+ | '''Exemplul 2:''' |
<haskell> |
<haskell> |
||
Prelude> map ($ 1) [(\x -> x+1) , (20+), (\y -> y *y) ] |
Prelude> map ($ 1) [(\x -> x+1) , (20+), (\y -> y *y) ] |
Revision as of 09:32, 23 January 2008
Folosind vechea noastra cunostinta map si operatorul $ putem sa transferam o singura valoare (argument) unei liste de functii:
Exemplul 1:
Prelude> map ($ 0) [(1+),(2+),(23+)]
[1,2,23]
Exemplul 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.
Pagina indexata la indexul Categories:Ro
<= Inapoi la pagina principala Ro/Haskell.
<- Inapoi la Intrebarile incepatorului Ro/Haskell.