Difference between revisions of "Cum se aplica o lista de functii pe o valoare ?"
Jump to navigation
Jump to search
m |
|||
Line 1: | Line 1: | ||
− | Folosind vechea noastra cunostinta '''map''' si operatorul '''$''' : |
+ | Folosind vechea noastra cunostinta '''map''' si operatorul '''$''' putem sa transferam o singura valoare (argument) unei liste de functii: |
+ | ---- |
||
+ | '''Ecemplul 1:''' |
||
<haskell> |
<haskell> |
||
Prelude> map ($ 0) [(1+),(2+),(23+)] |
Prelude> map ($ 0) [(1+),(2+),(23+)] |
||
Line 8: | Line 10: | ||
---- |
---- |
||
+ | '''Ecemplul 2:''' |
||
⚫ | |||
+ | <haskell> |
||
+ | 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> |
||
+ | </haskell> |
||
+ | |||
+ | Nota: Bineinteles ca functiile trebuie sa aiba acelasi tip. |
||
+ | ---- |
||
⚫ |
Revision as of 22:36, 22 December 2007
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.