Currying: Difference between revisions
Content added Content deleted
Line 1,025: | Line 1,025: | ||
<lang scheme> |
<lang scheme> |
||
1) just define function a binary function: |
1) just define function a binary function: |
||
{def power {lambda {:a :b} {pow :a :b}}} |
|||
-> power |
-> power |
||
2) and use it: |
2) and use it: |
||
{power 2 8} // power is a function waiting for two numbers |
|||
'{power 2 8} |
|||
-> 256 |
-> 256 |
||
{{power 2} 8} // {power 2} is a function waiting for the missing number |
|||
-> 256 |
-> 256 |
||
{S.map {power 2} {S.serie 1 10}} // S.map applies the {power 2} unary function |
|||
-> 2 4 8 16 32 64 128 256 512 1024 |
-> 2 4 8 16 32 64 128 256 512 1024 // to a sequence of numbers from 1 to 10 |
||
</lang> |
</lang> |
||