Comments
Browse / F# Cheatsheet
F# Cheatsheet
A concise reference for the F# programming language, covering syntax, data types, control flow, and common libraries.
Basic Syntax & Types
Basic Syntax
|
|
|
|
Value Binding |
|
|
Function Definition |
|
|
Type Inference |
F# infers types automatically. |
|
Semicolons |
Generally not required unless multiple expressions are on the same line. |
Basic Data Types
|
Integer |
|
|
Floating Point |
|
|
Boolean |
|
|
String |
|
|
Character |
|
|
Unit |
|
Type Annotations
|
You can explicitly specify types using Example: |
|
Function type annotation: |
Control Flow
If/Then/Else
|
|
Example:
|
Match Expressions
|
Powerful pattern matching construct.
|
|
Example:
|
Loops
|
|
Example:
|
|
|
Example:
|
Data Structures
Tuples
|
Definition |
|
|
Example |
|
|
Accessing Elements |
|
Lists
|
Definition |
|
|
Example |
|
|
Adding elements |
|
|
Common functions |
|
Arrays
|
Definition |
|
|
Example |
|
|
Accessing elements |
|
|
Slicing |
|
Records
|
Definition |
|
|
Example |
|
|
Accessing fields |
|
Discriminated Unions
|
Definition |
|
|
Example |
|
|
Pattern Matching |
|
Functions
Function Basics
|
Definition |
|
|
Example |
|
|
Calling a Function |
|
Lambda Expressions
|
Definition |
|
|
Example |
|
|
Usage |
|
Partial Application
|
Concept |
Applying some arguments to a function, resulting in a new function that accepts the remaining arguments. |
|
Example |
|
Function Composition
|
Operator |
|
|
Example |
|
Recursion
|
Keyword |
|
|
Example |
|