Haskell a la carte
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.
How to eat?
square x = x*x
- The function 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?