Introduction to Functional Programming in Haskell
1 / 46
Introduction to Functional Programming in Haskell 1 / 46 Outline - - PowerPoint PPT Presentation
Introduction to Functional Programming in Haskell 1 / 46 Outline Why learn functional programming? The essence of functional programming What is a function? Equational reasoning First-order vs. higher-order functions Lazy evaluation How to
1 / 46
2 / 46
Why learn functional programming? 3 / 46
Why learn functional programming? 4 / 46
The essence of functional programming 5 / 46
The essence of functional programming 6 / 46
The essence of functional programming 7 / 46
The essence of functional programming 8 / 46
The essence of functional programming 9 / 46
The essence of functional programming 10 / 46
void qsort(int low, int high) { int i = low, j = high; int pivot = numbers[low + (high-low)/2]; while (i <= j) { while (numbers[i] < pivot) { i++; } while (numbers[j] > pivot) { j--; } if (i <= j) { swap(i, j); i++; j--; } } if (low < j) qsort(low, j); if (i < high) qsort(i, high); } void swap(int i, int j) { int temp = numbers[i]; numbers[i] = numbers[j]; numbers[j] = temp; } The essence of functional programming 11 / 46
The essence of functional programming 12 / 46
The essence of functional programming 13 / 46
The essence of functional programming 14 / 46
The essence of functional programming 15 / 46
The essence of functional programming 16 / 46
The essence of functional programming 17 / 46
The essence of functional programming 18 / 46
The essence of functional programming 19 / 46
The essence of functional programming 20 / 46
The essence of functional programming 21 / 46
The essence of functional programming 22 / 46
How to functional program 23 / 46
How to functional program 24 / 46
How to functional program 25 / 46
How to functional program 26 / 46
How to functional program 27 / 46
How to functional program 28 / 46
How to functional program 29 / 46
How to functional program 30 / 46
How to functional program 31 / 46
How to functional program 32 / 46
How to functional program 33 / 46
How to functional program 34 / 46
How to functional program 35 / 46
How to functional program 36 / 46
How to functional program 37 / 46
Refactoring and reuse 38 / 46
Refactoring and reuse 39 / 46
Refactoring and reuse 40 / 46
Refactoring and reuse 41 / 46
Refactoring and reuse 42 / 46
Refactoring and reuse 43 / 46
Type inference 44 / 46
Type inference 45 / 46
Type inference 46 / 46