Programowanie w systemie UNIX/Haskell: Różnice pomiędzy wersjami

Usunięta treść Dodana treść
m →‎Kwadrat liczby: skłądanie
Linia 48:
|valign="top" style="border-right:1px dashed SlateBlue"|
 
<source lang=haskell>
<pre>
-- Haskell
square :: Int -> Int
square n = n*n
</source>
 
</pre>
|valign="top" style="border-right:1px dashed SlateBlue"|
 
 
<source lang=c>
// c
int square(int n) {
 
return n*n; }
 
Linia 67 ⟶ 63:
 
|}
===składanie funkcji ===
Składanie funkcji ( ang. function composition) za pomocą:
* operatora . ( ang. dot operator)
* stylu pointfree
 
<source lang=haskell>
-- the '.' operator is used to compose functions
-- result of sort is pipelined to reverse
desort = (reverse . sort)
-- the result is a descending sort
countdown = desort [2,8,7,10,1,9,5,3,4,6]
</source>
 
==Listy==