Lists, patterns and recursion
Lists are the first data structure of Haskell, and recursion replaces the loops of an imperative language. These fifteen lessons cover cons and append, ranges and comprehensions, pattern matching, where and let, and a recursion that carries an accumulator. The higher-order functions follow: map, filter, the two folds, and the sorting and searching of Data.List. Operator fixity and composition close the part.
013
Lists: cons, append and the total helpers
[] and :, ++, head and tail, length, null, reverse, why append is expensive
Open
014
Ranges and enumeration
[1..10], [1,3..9], [10,9..1], infinite ranges, enumFromThenTo
Open
015
List comprehensions
a generator, a guard, let in a comprehension, nested generators, a Pythagorean triple
Open
016
Pattern matching
function equations, the wildcard, as-patterns, list patterns, a match the compiler warns about
Open
017
case expressions
case of, matching a Maybe, nesting, case against equations
Open
018
where, let and scope
where on a definition, let in, let in do, the scope of each
Open
019
Recursion replaces loops
a base case, a recursive step, sum, product, replicate, the call stack
Open
020
Tail recursion and accumulators
an accumulator, go helpers, why a tail call still builds thunks
Open
021
map, filter, zipWith and flip
functions as arguments, map, filter, zipWith, flip, any and all
Open
022
Currying, partial application and sections
one argument at a time, partial application, operator sections, lambdas
Open
023
Operators, precedence and fixity
precedence, associativity, backticks, infixl and infixr, an operator of your own
Open
024
(.), ($) and point-free code
composition, $, flip ($), a pipeline, where point-free stops helping
Open
025
foldr, foldl and foldl'
the two folds, foldr1, foldl' from Data.List, a fold written by hand
Open
026
Sorting, searching and deduplication
sort, sortBy, nub, elem, lookup, minimum and maximum
Open
027
Splitting and joining text
words, unwords, lines, unlines, break, span, a word count
Open