A First [and Simple] F# Sample

Anything worth learning should not be simple. Learning Clojure was not simple, and hacking with C# for the first time was not simple either, so I should not expect simple while learning F#.

Here is a first small program, because I have found a dirth of regular simple examples out on the web, especially those calling .Net functions.

 open System
 open System.Threading
 open System.Collections.Generic
 open System.Linq
 open System.Text
 open System.Threading.Tasks
 open System.IO
 open Microsoft.VisualBasic.FileIO

let main argv =
    let parser = new TextFieldParser("test1.csv")
    parser.TextFieldType = FieldType.Delimited |> ignore
    let x = parser.SetDelimiters(",")

    let eod = parser.EndOfData
    if not eod then
        let column_headings = parser.ReadFields()
        printf "%A" column_headings |> ignore
0 // return an integer exit code

This is the contents of test1.csv

<br data-mce-bogus="1">




Leave a comment

Filed under F#

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s