Category Archives: Getting Started

First simple programs, interactive sessions

Reading and writing WAV audio files

The following example shows simple reading and writing (and later processing) of WAV audio files using File.ReadAllBytes, File.WriteAllBytes and BitConverter. > open System.IO;; > File.ReadAllBytes;; val it : string -> byte [] = <fun:clo@4> > File.WriteAllBytes;; val it : string … Continue reading

Posted in Getting Started, IO | 1 Comment

Basic MySQL Transactions

The following example shows how to access a MySQL database with F# on Mono. To try it out, please install the MySQL NET/Connector in advance. Firstly, lets create an example database and a mysql user account. ~> mysql -u root … Continue reading

Posted in Database, Getting Started | Leave a comment

ASP.NET Webforms and Event Handling

To create more active server pages as done in the first example, it is necessary to add code and reference elements of a page. The most simple way is to add a script section in the ‘index.aspx’ source. It may … Continue reading

Posted in Getting Started, Web | 1 Comment

ASP.NET with F# and Mono

ASP.NET is the implementation of server-side code based on .NET to create dynamic web pages. Mono does support ASP.NET with some additional configuration F# can also be used to create dynamic web content. As we need multiple elements to work … Continue reading

Posted in Getting Started, Web | 2 Comments

Interactive Session #11: Units of Measure

F# includes a language feature to annotate your code with units of measure like meter, second or kilogram, preferably from the SI system. These units are statically checked during compile time and will not be part of the compiled code. … Continue reading

Posted in Algorithms, Getting Started, Language | 1 Comment

Interactive Session #10: List, Array, Sequence

F# supports three different list-like data structures to store values of the same type: List, Array and Sequence. In this session we want to explore the similarities and differences among these three types. First lets instantiate values of each of … Continue reading

Posted in Getting Started, Language | 1 Comment

Interactive Session #9: Processing XML

Reading and interpreting XML data is performed through the System.Xml package. You need to create a new XmlDocument value and load the XML text into the XmlDocument. > open System.Xml;; > let txt = “<drawing><line><x>10.0</x><y>20.0</y><dx>50.0</dx> <dy>50.0</dy></line><circle><x>50.0</x><y>50.0</y><r>20.0</r> </circle></drawing>”;; val txt : … Continue reading

Posted in Getting Started, GUI, IO, Text | 1 Comment

Interactive Session #7: Text file I/O

Binary and text file access is provided through the module System.IO. The type File provides static methods to create, open, read and write files. File.CreateText creates a new file (if it exists already content is overwritten) in text mode. > … Continue reading

Posted in Getting Started, IO, Text | Leave a comment

Interactive Session #6: Winforms SplitContainer

The SplitContainer allows to add two forms separated by a bar to another form. First we need a form again. > open System.Windows.Forms;; > let f = new Form();; val f : Form = System.Windows.Forms.Form, Text: > f.Visible <- true;; … Continue reading

Posted in Getting Started, GUI | Leave a comment

Interactive Session #4: Command Line Arguments

The command line arguments are provided as a list of string. As usual the first element (index 0) is the path of the program itself. > System.Environment.GetCommandLineArgs();; val it : string [] = [|”/usr/local/lib/FSharp-2.0.0.0/bin/fsi.exe”|] Read more here: Environment.GetCommandLineArgs

Posted in Getting Started | Leave a comment