1 / 25

F# and its 11 features

F# and its 11 features. Guanru Li 2011 ACM class. F# is …. ... a programming language. F# is …. ... a functional programming language. F# is …. ... a functional programming language for .NET. F# is …. ... a functional and object oriented programming language for .NET.

kcastillo
Download Presentation

F# and its 11 features

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. F# and its 11 features Guanru Li 2011 ACM class

  2. F# is … ... a programming language.

  3. F# is … ... a functional programming language

  4. F# is … ... a functional programming language for .NET

  5. F# is … ... a functional and object oriented programming language for .NET

  6. F# is … ... a functional, object oriented and imperative programming language for .NET

  7. F# is … ... a multi-paradigm programming language for .NET

  8. F# is … ...a multi-paradigm programming language for .NET, ideally suited for technical, symbolic and algorithmic applications

  9. F#

  10. Why named F#? • C# • Functional programming

  11. Hello F#, Hello n factorial printfn "Hello F#!“ letrec factorial n = match n with | 0 -> 1 | _ -> n * factorial(n - 1)

  12. Feature 1 of 11 • Functional programming let f (g: int -> int) y = g y let increment x = x + 1 let a = f increment 100 • Lambda expression let f (g: int -> int) y = g y let a = f (fun x -> x + 1) 100

  13. Feature 2 of 11 • Compose the functions! let function1 x = x + 1 let function2 x = x * 2 let h = function1 >> function2 let a = h 100

  14. Feature 3 of 11 • Collection types for immutable data • Usage: ??

  15. Feature 4 of 11 • Pattern matching (x is a list) let length x = match x with | [] -> “0” | [ _ ] -> “1” | [ _; _ ] -> “2” | _ -> “Too Long!”

  16. Feature 5 of 11 • Discriminated unions type Shape = | Circle of float | Square of double let area myShape = match myShape with | Circle r -> 3.14*r*r | Square r -> s*s

  17. Feature 6 of 11 • Interactive programming

  18. Feature 7 of 11 • Lazy computations & lazy evaluation let x = 10 let result = lazy (x + 10) do something printfn "%d" (result.Force())

  19. Feature 8 of 11 • Object oriented • Class & inherit • Single inheritance

  20. Feature 9 of 11 • Imperative programming • Like C, C++, Java

  21. Feature 10 of 11 • Generics and type inference let makeList a b = [a; b] makeList<int> 1 2 let function1 a = a + 1

  22. Feature 11 of 11 • Asynchronous workflows • ??

  23. Reference • http://en.wikipedia.org/wiki/F_Sharp_(programming_language) ---- wikipedia F sharp • http://msdn.microsoft.com/zh-cn/library/ dd233181 ---- MSDN F# reference • http://developer.51cto.com/art/201004/192870.htm ---- 51CTO.com F# new features

  24. Q&A

More Related