##### Views

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

## 1 Apéritifs

Foretaste of an excellent meal.

  qsort :: Ord a => [a] -> [a]
qsort []     = []
qsort (x:xs) = qsort (filter (<x) xs) ++ [x] ++ qsort (filter (>x) xs))
Quicksort in three lines (!). Sorts not only integers but anything that can be compared.
  fibs = 1:1:zipWith (+) fibs (tail fibs)
The infinite list of fibonacci numbers. Just don't try to print all of it.
  linecount = interact $show . length . lines wordcount = interact$ show . length . words
Count the number of lines or words from standard input.

## 2 Entrées

How to eat?

  square x = x*x
The function $f(x)=x\cdot x$ which maps a number to its square. While we commonly write parenthesis around function arguments in mathematics and most programming languages, a simple space is enough in Haskell. We're going supply arguments all around, so why clutter the notation with unnecessary ballast?