O'Reilly logo

Get Programming with F#: A guide for .NET developers by Isaac Abraham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Basic F# syntax, types, and functions

// Define module MyCode in namespace Company.Rules (lesson 12) module Company.Rules.MyCode // Open System namespace open System // Define a simple value (lesson 4) let playerName = "Joe" // Create and unwrap a tuple (lesson 9) let playerTuple = playerName, 21 let name, age = playerTuple // Define and create a record (lesson 10) type Player = { Name : string; Score : int; Country : string } let player = { Name = playerName; Score = 0; Country = "GB" } // Function definition with copy-and-update record syntax (lessons 10, 11) let increaseScoreBy score p = { p with Score = p.Score + score } // Piping functions (lesson 11) player |> increaseScoreBy 50 |> printfn "%A" // Function with basic pattern matching and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required