Lesson 20. Program flow in F#
In C# and VB .NET, we have a variety of ways of performing what I consider program flow: branching mechanisms and, to an extent, loops. In this lesson, we’ll compare and contrast those features with equivalents in F#, looking at the following:
- for and while loops
- If/then statements and expressions
- Switch/case statements
- Pattern matching
When you’re finished, you’ll have a good idea of how to perform all sorts of complex conditional logic much more succinctly than you might be used to.
20.1. A tour around loops in F#
I cover loops briefly in this lesson because the F# side of things has a slightly different syntax compared to C# and VB .NET, with similar behavior. This leaves us more room to focus on branching ...
Get Get Programming with F# now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.