SlideShare a Scribd company logo
1 of 22
A language you can brag about
Functional programming

     The new hotness
    Next “big” .NET language

     CTP this summer
OCaml offspring

    Created by MS Research

    Mixed mode language

     Functional
     OO
     Imperative (if you must)
    Statically typed

Yay! Type inference
                 
let x = 7
                     ...also, immutable
                 
let s = quot;kurtquot;
let pi = 3.142       So, really just “values”
                 
let l = ['a';'b';'c';]
// char list or list<char>
                                 Singly linked list
                             
                                 Still immutable!
                             
let digits = [0..9]
// int list
IEnumerable<T>
                    
let s = {1..10}
                        Useful for computing
                    
// seq[1;2;3;...]
                        unbounded lists
let me = (quot;kurtquot;, 6.0)
                             Typed groups of values
                         
// string * float
                             Can “hold” anything
                         
let point3d = (0,0,0)        Basically awesome
                         
// int * int * int
let add x y = x + y
                           Like any other value
                       
// int -> int -> int
                           More type inference
                       
let eight = add 3 5        Returns last expression
                       
// eight = 8
Look ma! Generics!
                         
let group x y = (x,y)
// 'a -> 'b -> 'a * 'b        Auto-generalization
let rec fib n =
    if n < 2 then
        n
                              Explicitly recursive
                          
    else
                              Tail recursion
                          
        (fib (n - 1)) +
        (fib (n - 2))
type name = string
type number = int
type date = System.DateTime
type meeting =
    | Personal of name   * date
    | Phone    of number * date

let review = Personal(quot;Jasminequot;,System.DateTime.Now)
let call = Phone(8675309, System.DateTime.Now)
let what_to_do (m : meeting) =
    match m with
    | Personal(name,date) ->
        printfn quot;Meeting with %s at %Aquot; name date
    | Phone(phone, date) ->
        printfn quot;Call %A at %Aquot; phone date
Functions are basic units of a program

    We can mix them up in interesting ways

     Less OO design patterns!
    “Cheap” functions are good

     Code is more expressive
let add3 = add 3
let add x y = x + y
                       // int -> int
// int -> int -> int
let even x = x % 2 = 0
                            // int -> bool
                            let numbers = [1..20]
let (|>) x f = f x          // int list
                            let evens =
// 'a -> ('a -> 'b) -> 'b
                                numbers |>
                                    List.filter even
                            // int list
List.fold_left
                           // ('b -> 'a -> 'b) ->
List.map
                           // 'b ->
// ('a -> 'b) ->
                           // 'a list ->
// 'a list ->
                           // 'b
// 'b list
                           [1..10] |> List.fold_left
[1..10] |> List.map add3
                             (fun acc x -> acc + x) 0
// [4;5;6;..;13]
                           // 55
2520 is the smallest number that can be

    divided by each of the numbers from 1 to 10
    without any remainder.
    What is the smallest number that is evenly

    divisible by all of the numbers from 1 to 20?
                                      - Project Euler
                                   projecteuler.net
“Mutable” keyword

     For real variables
    There are imperative loops

     Try not to use it too much
F# can be OO

     Classes
     Interfaces
     Inheritance
    Cross language work

     “Hide” implementation
type OrderLine(n:string, q:int, p:float) =
    let mutable currName = n
    let mutable currQuantity = q
    let mutable currPrice = p
    new (name, price) = OrderLine(name, 1, price)
    member x.Name
        with get() = currName
        and set name = currName <- name
    member x.SubTotal with get() =
        (Float.of_int quantity) * price
    member x.OneMore() =
        currQuantity <- currQuantity + 1
        currQuantity
Why functional programming?

     Easy to build incrementally
     Simplified testing
     Concurrency!
    Imperative can be good too

     At times, it’s wickedly fast
     It’s what we know
F# Presentation

More Related Content

Viewers also liked

Sequential file programming patterns and performance with .net
Sequential  file programming patterns and performance with .netSequential  file programming patterns and performance with .net
Sequential file programming patterns and performance with .netMichael Pavlovsky
 
Moq Presentation
Moq PresentationMoq Presentation
Moq PresentationLynxStar
 
Mock driven development using .NET
Mock driven development using .NETMock driven development using .NET
Mock driven development using .NETPuneet Ghanshani
 
Domain Driven Design with the F# type System -- NDC London 2013
Domain Driven Design with the F# type System -- NDC London 2013Domain Driven Design with the F# type System -- NDC London 2013
Domain Driven Design with the F# type System -- NDC London 2013Scott Wlaschin
 
Functional Programming in C# and F#
Functional Programming in C# and F#Functional Programming in C# and F#
Functional Programming in C# and F#Alfonso Garcia-Caro
 
Principles and patterns for test driven development
Principles and patterns for test driven developmentPrinciples and patterns for test driven development
Principles and patterns for test driven developmentStephen Fuqua
 
An Introduction to Unit Test Using NUnit
An Introduction to Unit Test Using NUnitAn Introduction to Unit Test Using NUnit
An Introduction to Unit Test Using NUnitweili_at_slideshare
 
Clean Unit Test Patterns
Clean Unit Test PatternsClean Unit Test Patterns
Clean Unit Test PatternsFrank Appel
 
Unit testing best practices
Unit testing best practicesUnit testing best practices
Unit testing best practicesnickokiss
 
Unit Testing Concepts and Best Practices
Unit Testing Concepts and Best PracticesUnit Testing Concepts and Best Practices
Unit Testing Concepts and Best PracticesDerek Smith
 
Undertaking Cemetery Rehabilitation
Undertaking  Cemetery RehabilitationUndertaking  Cemetery Rehabilitation
Undertaking Cemetery Rehabilitationchicora
 
Ramesh Curriculum Vitae
Ramesh Curriculum VitaeRamesh Curriculum Vitae
Ramesh Curriculum Vitaeramesh77uom
 
Gei015.09 Seminar032409
Gei015.09 Seminar032409Gei015.09 Seminar032409
Gei015.09 Seminar032409sourcelv
 
09April2009 Assembly Presentation
09April2009   Assembly Presentation09April2009   Assembly Presentation
09April2009 Assembly Presentationnurarafah
 
Ataqueal Coraz N
Ataqueal Coraz NAtaqueal Coraz N
Ataqueal Coraz Namigo2007
 
Avalon Cosmetics Inc Pp
Avalon Cosmetics Inc PpAvalon Cosmetics Inc Pp
Avalon Cosmetics Inc PpMikeE21286
 

Viewers also liked (20)

F# intro
F# introF# intro
F# intro
 
Sequential file programming patterns and performance with .net
Sequential  file programming patterns and performance with .netSequential  file programming patterns and performance with .net
Sequential file programming patterns and performance with .net
 
Moq Presentation
Moq PresentationMoq Presentation
Moq Presentation
 
Mock driven development using .NET
Mock driven development using .NETMock driven development using .NET
Mock driven development using .NET
 
Domain Driven Design with the F# type System -- NDC London 2013
Domain Driven Design with the F# type System -- NDC London 2013Domain Driven Design with the F# type System -- NDC London 2013
Domain Driven Design with the F# type System -- NDC London 2013
 
Functional Programming in C# and F#
Functional Programming in C# and F#Functional Programming in C# and F#
Functional Programming in C# and F#
 
Principles and patterns for test driven development
Principles and patterns for test driven developmentPrinciples and patterns for test driven development
Principles and patterns for test driven development
 
Unit Testing (C#)
Unit Testing (C#)Unit Testing (C#)
Unit Testing (C#)
 
TDD, BDD and mocks
TDD, BDD and mocksTDD, BDD and mocks
TDD, BDD and mocks
 
An Introduction to Unit Test Using NUnit
An Introduction to Unit Test Using NUnitAn Introduction to Unit Test Using NUnit
An Introduction to Unit Test Using NUnit
 
Clean Unit Test Patterns
Clean Unit Test PatternsClean Unit Test Patterns
Clean Unit Test Patterns
 
Unit testing best practices
Unit testing best practicesUnit testing best practices
Unit testing best practices
 
Unit Testing Concepts and Best Practices
Unit Testing Concepts and Best PracticesUnit Testing Concepts and Best Practices
Unit Testing Concepts and Best Practices
 
Undertaking Cemetery Rehabilitation
Undertaking  Cemetery RehabilitationUndertaking  Cemetery Rehabilitation
Undertaking Cemetery Rehabilitation
 
CRM
CRMCRM
CRM
 
Ramesh Curriculum Vitae
Ramesh Curriculum VitaeRamesh Curriculum Vitae
Ramesh Curriculum Vitae
 
Gei015.09 Seminar032409
Gei015.09 Seminar032409Gei015.09 Seminar032409
Gei015.09 Seminar032409
 
09April2009 Assembly Presentation
09April2009   Assembly Presentation09April2009   Assembly Presentation
09April2009 Assembly Presentation
 
Ataqueal Coraz N
Ataqueal Coraz NAtaqueal Coraz N
Ataqueal Coraz N
 
Avalon Cosmetics Inc Pp
Avalon Cosmetics Inc PpAvalon Cosmetics Inc Pp
Avalon Cosmetics Inc Pp
 

Similar to F# Presentation

Similar to F# Presentation (20)

Python quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung FuPython quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung Fu
 
Scala 2 + 2 > 4
Scala 2 + 2 > 4Scala 2 + 2 > 4
Scala 2 + 2 > 4
 
Kotlin
KotlinKotlin
Kotlin
 
Ruby Language - A quick tour
Ruby Language - A quick tourRuby Language - A quick tour
Ruby Language - A quick tour
 
Scala introduction
Scala introductionScala introduction
Scala introduction
 
Python for High School Programmers
Python for High School ProgrammersPython for High School Programmers
Python for High School Programmers
 
JBUG 11 - Scala For Java Programmers
JBUG 11 - Scala For Java ProgrammersJBUG 11 - Scala For Java Programmers
JBUG 11 - Scala For Java Programmers
 
Groovy
GroovyGroovy
Groovy
 
C tutorial
C tutorialC tutorial
C tutorial
 
Python Workshop
Python  Workshop Python  Workshop
Python Workshop
 
Python
PythonPython
Python
 
LEX & YACC TOOL
LEX & YACC TOOLLEX & YACC TOOL
LEX & YACC TOOL
 
My First Rails Plugin - Usertext
My First Rails Plugin - UsertextMy First Rails Plugin - Usertext
My First Rails Plugin - Usertext
 
C to perl binding
C to perl bindingC to perl binding
C to perl binding
 
Python Workshop Part 2. LUG Maniapl
Python Workshop Part 2. LUG ManiaplPython Workshop Part 2. LUG Maniapl
Python Workshop Part 2. LUG Maniapl
 
Falcon初印象
Falcon初印象Falcon初印象
Falcon初印象
 
Functional Programming in F#
Functional Programming in F#Functional Programming in F#
Functional Programming in F#
 
Bti1022 lab sheet 8
Bti1022 lab sheet 8Bti1022 lab sheet 8
Bti1022 lab sheet 8
 
Bti1022 lab sheet 8
Bti1022 lab sheet 8Bti1022 lab sheet 8
Bti1022 lab sheet 8
 
SWP - A Generic Language Parser
SWP - A Generic Language ParserSWP - A Generic Language Parser
SWP - A Generic Language Parser
 

Recently uploaded

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 

Recently uploaded (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

F# Presentation

  • 1. A language you can brag about
  • 2. Functional programming   The new hotness Next “big” .NET language   CTP this summer
  • 3. OCaml offspring  Created by MS Research  Mixed mode language   Functional  OO  Imperative (if you must) Statically typed 
  • 4. Yay! Type inference  let x = 7 ...also, immutable  let s = quot;kurtquot; let pi = 3.142 So, really just “values” 
  • 5. let l = ['a';'b';'c';] // char list or list<char> Singly linked list  Still immutable!  let digits = [0..9] // int list
  • 6. IEnumerable<T>  let s = {1..10} Useful for computing  // seq[1;2;3;...] unbounded lists
  • 7. let me = (quot;kurtquot;, 6.0) Typed groups of values  // string * float Can “hold” anything  let point3d = (0,0,0) Basically awesome  // int * int * int
  • 8. let add x y = x + y Like any other value  // int -> int -> int More type inference  let eight = add 3 5 Returns last expression  // eight = 8
  • 9. Look ma! Generics!  let group x y = (x,y) // 'a -> 'b -> 'a * 'b  Auto-generalization
  • 10. let rec fib n = if n < 2 then n Explicitly recursive  else Tail recursion  (fib (n - 1)) + (fib (n - 2))
  • 11. type name = string type number = int type date = System.DateTime type meeting = | Personal of name * date | Phone of number * date let review = Personal(quot;Jasminequot;,System.DateTime.Now) let call = Phone(8675309, System.DateTime.Now)
  • 12. let what_to_do (m : meeting) = match m with | Personal(name,date) -> printfn quot;Meeting with %s at %Aquot; name date | Phone(phone, date) -> printfn quot;Call %A at %Aquot; phone date
  • 13. Functions are basic units of a program  We can mix them up in interesting ways   Less OO design patterns! “Cheap” functions are good   Code is more expressive
  • 14. let add3 = add 3 let add x y = x + y // int -> int // int -> int -> int
  • 15. let even x = x % 2 = 0 // int -> bool let numbers = [1..20] let (|>) x f = f x // int list let evens = // 'a -> ('a -> 'b) -> 'b numbers |> List.filter even // int list
  • 16. List.fold_left // ('b -> 'a -> 'b) -> List.map // 'b -> // ('a -> 'b) -> // 'a list -> // 'a list -> // 'b // 'b list [1..10] |> List.fold_left [1..10] |> List.map add3 (fun acc x -> acc + x) 0 // [4;5;6;..;13] // 55
  • 17. 2520 is the smallest number that can be  divided by each of the numbers from 1 to 10 without any remainder. What is the smallest number that is evenly  divisible by all of the numbers from 1 to 20? - Project Euler projecteuler.net
  • 18. “Mutable” keyword   For real variables There are imperative loops   Try not to use it too much
  • 19. F# can be OO   Classes  Interfaces  Inheritance Cross language work   “Hide” implementation
  • 20. type OrderLine(n:string, q:int, p:float) = let mutable currName = n let mutable currQuantity = q let mutable currPrice = p new (name, price) = OrderLine(name, 1, price) member x.Name with get() = currName and set name = currName <- name member x.SubTotal with get() = (Float.of_int quantity) * price member x.OneMore() = currQuantity <- currQuantity + 1 currQuantity
  • 21. Why functional programming?   Easy to build incrementally  Simplified testing  Concurrency! Imperative can be good too   At times, it’s wickedly fast  It’s what we know