Tuesday, 13 August 2013

For loop in F#

Tutorial 2

Define list of numbers
Create for loop to display results.


// Learn more about F# at http://fsharp.net
// See the 'F# Tutorial' project for more help.

open System

printfn "Started"

// define list
let list1 = [ 1; 2; 3; 4; 5; ]

//loop through all
for i in list1 do
   printfn "%d" i

// i squared
for i in list1 do
    printfn "%d squared %d" i (i*i)

printfn "Press any key to exit"

Your result