F# Pages

Dot Net Perls has example pages for many languages, with explanations and code side by side (for easy understanding).


Create a dictionary with dict. Use Item, Keys and TryGetValue to access the dictionary.F# dict: Dictionary Examples, Item and Keys


Instantiate arrays of strings and ints. Use ranges, accesses elements and stores values in arrays.F# Array Examples

Downcast, upcast.

Cast objects in the type hierarchy with the upcast and downcast keywords.F# Downcast and upcast Example


Handle exceptions and use the failwith and raise operators. Use failwith inside match.F# Failwith: Exception Handling


Use System.IO and StreamReader to read lines of text files. Specify the use, and open, keywords.F# Files: open System.IO, use StreamReader

For, while.

Loop over ranges and collections with the for-to, for-in and while loops.F# For and While Loop Examples: For To, For In

Fun, lambdas.

Describe higher-order procedures and the fun keyword. Specify lambda expressions.F# Fun Keyword: Lambda Expressions, Functions

If, elif.

Add branches with the if, elif and else keywords. Test conditions in programs.F# If, elif and else Examples


Review keywords in the F# language. Browse examples that use these keywords.F# Keywords


Understand the let, let mutable and lightweight syntax. See functions, variables and temporary variables.F# Let Keyword: let mutable, Errors


Store collections of strings and ints with lists. Use a for-loop upon a list.F# List Examples, String Lists


Test data, and direct the flow of control, with the match keyword. Match inside a method.F# Match Keyword


Perform computations on numbers with math operators. Call pown, abs, floor and ceil.F# Math Operators: abs, floor and ceil


Learn about option types. Access the IsNone, IsSome and Value properties on an option.F# Option int Example: IsNone, IsSome and Value


Write values to the screen with the printfn and printf methods. See format codes for strings and ints.F# Printfn Examples: printf, Formats


Create records with named fields, using the type and with keywords.F# Record Examples: Type, With Keywords

Remove duplicates.

Invoke Seq.distinct to remove duplicates from a list. Convert from the seq back into a list or array.F# Remove Duplicates From List (Seq.distinct)


Use the Seq module and evaluate sequences with methods like sum and where.F# Seq Examples: Seq.sum, Seq.where


Sort a list with the List.sort function. Use sortBy with a fun to customize the sort order.F# Sort List Examples: sortBy, Lambdas


Understand strings and string methods. Use .NET Framework methods in F# constructs.F# String Examples:


Learn the syntax of tuples. Create tuples, unpack tuples and return tuples from methods.F# Tuple Examples


Use types with members and mutable fields. Create instances of the types.F# Type Example: member, get and set
Dot Net Perls
© 2007-2019 Sam Allen. All rights reserved. Written by Sam Allen,