Talk given at http://techmeetup.co.uk/ on 25th of September 2013.
Contact me at:
@KeithDHar
keithharrisonuk@yahoo.co.uk
http://www.linkedin.com/in/keithdharrison
We're hiring F# developers:
http://careers.stackoverflow.com/uk/company/hymans-robertson
8. public class Multiplier {
public int Factor;
public int Calculate(int value) {
return value * Factor;
}
}
var tenMultiplier = new Multiplier { Factor = 10 };
var result = tenMultiplier.Calculate(2);
9. let createMultiplier (factor) =
fun x -> x * factor
let multiplyByTen = createMultiplier(10)
let result = multiplyByTen(2)
10.
11. let filter people =
let results = new List<Person>()
for person in people do
if person.Age > 30 then
results.Add(person)
results
12. let filter people age =
let results = new List<Person>()
for person in people do
if person.Age > age then
results.Add(person)
results
13. let filter people =
let results = new List<Person>()
for person in people do
if person.Sex = Sex.Male then
results.Add(person)
results
14. let filter filterFunction people =
let results = new List<Person>()
for person in people do
if filterFunction() then
results.Add(person)
results
15. let filter filterFunction people =
let results = new List<Person>()
for person in people do
if filterFunction() then
results.Add(person)
results
filter (fun p -> p.Age > 30) personList
filter (fun p -> p.Age > 40) personList
filter (fun p -> p.Sex = Sex.Male) personList
16. let isOver30 p = p.Age > 30
let isOver40 p = p.Age > 40
let isMale p = p.Sex = Sex.Male
filter isOver30 personList
filter isOver40 personList
filter isMale personList
I’m keithharrisonI’m a .Net Developer at Hymans RobertsonHere to talk about why Hymans use F#
Start with a bit of back groundWho are Hymans?Actuarial Consultancy FirmModel risk using complex mathematical modelsFor example in a pension scheme calculate how much money you need today to pay each member till the last one dies. Mortality, pay rises, how long each member stay with the company
Problem?Port legacy excel application to .NetInteroperation with other systemsUnit Testing
What problem does F# solve with F#?Familiar to someone with a maths backgroundLeverage maths skills
Compose maths formulas to solve different problemsCalculation such as mortality, discounting cashflows are used to solve lots of different problems.
How is F# familiar to people with a strong maths background?
C# code.You need to understand, classes, access modifiers, scope, constructors, object initialisers
Same solution in F#Explain F# syntax‘let’ names a value or a functionStrongly typed, Types are inferredClosure
Explaincomposibility
What if we wanted to filter people over 40?
Add age variableWhat if we wanted to filter Men?
Same as previous functions except if statement
Same as previous functions except if statement
Multi - paradigm
ConclusionPorted legacy system to F#Quickly train up actuaries to expand the teamReuse the math functionsPragmatic convert imperative to F# -> function and use power of .Net framework