// F# program that uses fractions.dll, which was written in C# // Please read first and pay attention to details. #light #r "c:\\cygwin\\home\\cliang\\csc123\\fractions.dll";; // EDIT PATH! open System; // define a list of numbers that can contain integers and fractions type number = Rat of fraction | Int of int;; type nlist = Cons of number*nlist | Nil;; // function that prints every element of an nlist: let rec printnl = function | Nil -> Console.WriteLine(""); // carriage return | Cons(Int(n),t) -> Console.Write(string(n)+" "); printnl t; | Cons(Rat(r),t) -> Console.Write(r.ToString()+" "); printnl t;; let half = fraction(1,2); let quarter = new fraction(1,4); // "new" is optional let M = Cons(Int(2),Cons(Rat(half),Cons(Int(4),Cons(Rat(quarter),Nil)))); printnl M; // Run this program in F# by starting interactive console and type // #load "c:\\path..\\numlist.fs";;