lectures.alex.balgavy.eu

Lecture notes from university.
git clone git://git.alex.balgavy.eu/lectures.alex.balgavy.eu.git
Log | Files | Refs | Submodules

Haskell.md (468B)


      1 +++
      2 title = "Haskell"
      3 +++
      4 
      5 # Haskell
      6 Application by juxtaposition (F M):
      7 
      8 ```haskell
      9 head [1,2]
     10 ```
     11 
     12 Partial application:
     13 
     14 ```hs
     15 sum = foldr (+) 0
     16 ```
     17 
     18 Anonymous function (λx.x):
     19 
     20 ```hs
     21 \x -> x
     22 ```
     23 
     24 Infinite lists:
     25 
     26 ```hs
     27 ones = 1:ones   -- define an infinite list
     28 head ones       -- => 1
     29 ```
     30 
     31 Lazy evaluation does leftmost outermost.
     32 
     33 If it wasn't lazy, innermost would fuck shit up:
     34 
     35 ```
     36 head (1:ones) → head (1:1:ones) → head (1:1:1:ones) → ... → crap
     37 ```