1. F#, C# Functioneel vs. Imperatief Quadrant februari 2011 Andries Nieuwenhuize
2. Inhoud Doel: Bewustwording multiparadigmatisch programmeren; Introductie F# Scope: Imperatief vs. Functioneel Live coding (F# en C#) Step-in via generics 30 min.
3. Functioneel vs. imperatief a = a + 1 varlst = new List<int>() {1, 5, 0} var min = lst[0]; for (var i = 0; i < lst.Length; i++) {if(lst[i] < min) min = lst[i]; } b = a + 1 [1; 5; 0] |> List.sort |> List.head
4. Generics > Martin Odersky (Java) (Java<T>, Scala) Voor: newStringDictionary() Na: new Dictionary<string, string>(); <double, int> > .NET |> Don Syme (.NET<T> , F#)
5. F# Essentials (‘a, ‘b) tuple |> foreward pipe operator func(arg) wordt arg |> func ::list als head :: tail zowel addition als seperation []list (empty) [1;2;3] list met elementen rec Martin zegt: (a) Luister naar wat Martin zegt (tail recursive) (b) Onthoud wat Martin zegt
7. Resumé C# heeft generics, F# is generic Haal concept en implementatie uit elkaar Denk in transformaties Gebruik hiervoor higher-order functies State is eng
Imperative : based on CPU’s fetch-decode-execute cycle. development of a sequence of commands which manipulate data to produce the resultFunctional:views the process of program development as the construction of “black boxes,” each accepts inputs and produces outputs
Haal het concept en de implementatie uit elkaar. Laat dit laatste over aan de programmeur.Uitleggen foreward pipe operator