Fsharp shdh 40 lightning talk

623 views

Published on

A 5 minute lightning talk given at SHDH 40 on F#.

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
623
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Fsharp shdh 40 lightning talk

  1. 1. Some F# Highlights<br />Matt Harrington<br />mbh.work@gmail.com<br />
  2. 2. Dealing With Concurrency<br />Hire an expert, or …<br />Software Transactional Memory, or …<br />Functional Programming.<br />-Unknown<br />
  3. 3. Free, as in beer<br />Free standalone compiler for .NET (Windows or Mono).<br />Syntax highlighting for TextMate, vim, emacs, TextPad, jedit, and others.<br />IDEs:<br />MonoDevelop<br />SharpDevelop<br />Visual Studio Shell<br />Microsoft Research Shared Source License<br />
  4. 4. Robin Milner<br />University of Edinburgh<br />ML – 1970s<br />Don Syme<br />MSR Cambridge<br />F# - 2002<br />Xavier Leroy, et al.<br />INRIA, France<br />Ocaml - 1996<br />
  5. 5.
  6. 6. FP<br /><ul><li>Monads
  7. 7. Asynchronous programming
  8. 8. Pipeline operator |>
  9. 9. Currying
  10. 10. Continuations
  11. 11. Memoization</li></ul>First class functions<br />Immutability<br />Recursion<br />Type inference<br />Pattern matching<br />Lists, sequences, tuples, records, discriminated unions<br />Optiontype<br />
  12. 12. OO<br />Classes<br />Inheritance<br />Interfaces<br />Structs<br />Properties<br />Delegates<br />Enums<br />Mutability<br />
  13. 13. Tail Call Optimization<br />.method public static int32 g(int32 x) cil managed<br />{<br /> .maxstack 5<br /> L_0000: nop<br /> L_0001: ldarg.0 <br /> L_0002: ldc.i4.0 <br /> L_0003: ble.s L_0007<br /> L_0005: br.s L_0009<br /> L_0007: br.s L_0019<br /> L_0009: newobj instance void Program/g@9::.ctor()<br /> L_000e: ldarg.0 <br /> L_000f: ldc.i4.1 <br /> L_0010: sub <br />L_0011: tail <br /> L_0013: call int32 Program::f(class [FSharp.Core]Microsoft.<snip>)<br /> L_0018: ret <br /> L_0019: ldarg.0 <br /> L_001a: ret <br />}<br />
  14. 14. Units of Measure<br />[<Measure>]<br />type kilogram<br />letbowlingBall = 7.26<kilogram><br />let force (mass: float<kilogram>) = mass * 9.8<br />
  15. 15. Pipeline operator<br />let numbers = [1 .. 100]<br />let square x = x * x<br />letsumOfSquares =<br />numbers |> List.mapsquare<br />|> List.sum<br />
  16. 16. Euler Problem #7<br />let isPrimenum = <br />letupperDivisor = int32(sqrt(float num)) <br />matchnumwith <br /> | 0 | 1 -> false <br /> | 2 -> true <br /> | n ->seq { 2 .. upperDivisor } |> <br />Seq.forall(fun x ->num % x <> 0) <br />let primes = Seq.initInfinite id |> Seq.filterisPrime<br />let nthPrime n = Seq.nth n primes <br />printfn "The 10001st prime number is %i." <br /> (nthPrime 10001) <br />Code from "Juliet" on StackOverflow.<br />
  17. 17. More…<br />Matt Harrington: mbh.work@gmail.com<br />SFsharp.org<br />Luca Bolognese’s video (see links on SFsharp.org)<br />Programming F# by Chris Smith<br />

×