Different Types of For Loops in F#

Published on August 10, 2014 by Senthil Kumar

Filed under F#

Last modified August 10, 2014

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 4 (3 votes)

This article have been viewed 18086 times

F# supports 3 different types of For Loops . These include

  • For…to – This is  astandard for loop
  • For .. In – This is similar to For Each in C#
  • for…downto

Different Types of For Loops in F#

Below is a code snippet demonstrating the different For Loops in F#

// AbundantCode F# Tutorials and Code snippets
open System
let main argv =
    // For Loops in F#
    for indexer = 10 to 50 do
    for indexer = 50 downto 10 do
    for indexer in [10..50] do
    let retval = Console.ReadLine()
    0 // return an integer exit code

Leave a Comment


You might be Interested in these Posts

How to convert Nullable int to integer in C# ?

You can convert the Nullable Integer to Integer in C# using one of the below methods. 1. Using null...

FSharp Interactive Commands

FSharp Interactive UI includes few good number of commands which can be used by the F# Developers . ...

#time switch to measure the execution time in F#

If you want to measure the execution time of your F# code , you can use the #time attribute which le...