
- F# Basic Tutorial
- F# - Home
- F# - Overview
- F# - Environment Setup
- F# - Program Structure
- F# - Basic Syntax
- F# - Data Types
- F# - Variables
- F# - Operators
- F# - Decision Making
- F# - Loops
- F# - Functions
- F# - Strings
- F# - Options
- F# - Tuples
- F# - Records
- F# - Lists
- F# - Sequences
- F# - Sets
- F# - Maps
- F# - Discriminated Unions
- F# - Mutable Data
- F# - Arrays
- F# - Mutable Lists
- F# - Mutable Dictionary
- F# - Basic I/O
- F# - Generics
- F# - Delegates
- F# - Enumerations
- F# - Pattern Matching
- F# - Exception Handling
- F# - Classes
- F# - Structures
- F# - Operator Overloading
- F# - Inheritance
- F# - Interfaces
- F# - Events
- F# - Modules
- F# - Namespaces
- F# Useful Resources
- F# - Quick Guide
- F# - Useful Resources
- F# - Discussion
F# - Nested Loops
F# programming language allows to use one loop inside another loop.
Syntax
The syntax for a nested for loop statement could be as follows −
for var1 = start-expr1 to end-expr1 do for var2 = start-expr2 to end-expr2 do ... // loop body
The syntax for a nested while loop statement could be as follows −
while test-expression1 do while test-expression2 do body-expression
Example
let main() = for i = 1 to 5 do printf "\n" for j = 1 to 3 do printf "*" main()
When you compile and execute the program, it yields the following output −
*** *** *** *** ***
fsharp_loops.htm
Advertisements