1- // This sample will guide you through elements of the F# language.
1+ // This sample will guide you through elements of the F# language.
22//
33// *******************************************************************************************************
44// To execute the code in F# Interactive, highlight a section of code and press Alt-Enter or right-click
3131// - Recursive functions
3232// - Record types
3333// - Union types
34- // - Option types
35- // - Pattern matching
36- // - Units of measure
34+ // - Option types
35+ // - Pattern matching
36+ // - Units of measure
3737// - Parallel array programming
3838// - Using events
3939// - Database access using type providers
@@ -64,10 +64,10 @@ module Integers =
6464module BasicFunctions =
6565
6666 // Use 'let' to define a function that accepts an integer argument and returns an integer.
67- let func1 x = x* x + 3
67+ let func1 x = x* x + 3
6868
6969 // Parenthesis are optional for function arguments
70- let func1a ( x ) = x* x + 3
70+ let func1a ( x ) = x* x + 3
7171
7272 /// Apply the function, naming the function return result using 'let'.
7373 /// The variable type is inferred from the function return type.
@@ -179,7 +179,7 @@ module Lists =
179179 if ( i+ j) % 2 = 1 then
180180 yield ( i, j) ]
181181
182- /// Square the numbers in numberList, using the pipeline operator to pass an argument to List.map
182+ /// Square the numbers in numberList, using the pipeline operator to pass an argument to List.map
183183 let squares =
184184 numberList
185185 |> List.map ( fun x -> x* x)
@@ -205,7 +205,7 @@ module DefiningClasses =
205205
206206 // 'this' specifies a name for the object's self identifier.
207207 // In instance methods, it must appear before the member name.
208- member this.DX = dx
208+ member this.DX = dx
209209
210210 member this.DY = dy
211211
@@ -264,7 +264,7 @@ type ReadFile() =
264264 member this.ReadLine () = file.ReadLine()
265265
266266 // this class's implementation of IDisposable members
267- interface System.IDisposable with
267+ interface System.IDisposable with
268268 member this.Dispose () = file.Close()
269269
270270
@@ -359,9 +359,9 @@ module RecursiveFunctions =
359359 /// Computes the greatest common factor of two integers.
360360 // Since all of the recursive calls are tail calls, the compiler will turn the function into a loop,
361361 // which improves performance and reduces memory consumption.
362- let rec greatestCommonFactor a b =
362+ let rec greatestCommonFactor a b =
363363 if a = 0 then b
364- elif a < b then greatestCommonFactor a ( b - a)
364+ elif a < b then greatestCommonFactor a ( b - a)
365365 else greatestCommonFactor ( a - b) b
366366
367367 /// Computes the sum of a list of integers using recursion.
@@ -472,19 +472,19 @@ module OptionTypes =
472472 /// They are used extensively in F# code to represent the cases where many other
473473 /// languages would use null references.
474474
475- type Customer = { zipCode : decimal option }
475+ type Customer = { ZipCode : decimal option }
476476
477477 /// Abstract class that computes the shipping zone for the customer's zip code,
478478 /// given implementations for the 'getState' and 'getShippingZone' abstract methods.
479479 [<AbstractClass>]
480480 type ShippingCalculator =
481- abstract getState : decimal -> string option
482- abstract getShippingZone : string -> int
481+ abstract GetState : decimal -> string option
482+ abstract GetShippingZone : string -> int
483483
484484 /// Return the shipping zone corresponding to the customer's ZIP code
485485 /// Customer may not yet have a ZIP code or the ZIP code may be invalid
486- member this.customerShippingZone ( customer : Customer ) =
487- customer.zipCode |> Option.bind this.getState |> Option.map this.getShippingZone
486+ member this.CustomerShippingZone ( customer : Customer ) =
487+ customer.ZipCode |> Option.bind this.GetState |> Option.map this.GetShippingZone
488488
489489
490490
@@ -495,7 +495,7 @@ module OptionTypes =
495495module PatternMatching =
496496
497497 /// A record for a person's first and last name
498- type Person = {
498+ type Person = {
499499 First : string
500500 Last : string
501501 }
@@ -590,7 +590,7 @@ module Events =
590590 simpleEvent.Trigger( 5 )
591591
592592 // create instance of Event that follows standard .NET convention: (sender, EventArgs)
593- let eventForDelegateType = new Event< EventHandler, EventArgs>()
593+ let eventForDelegateType = new Event< EventHandler, EventArgs>()
594594
595595 // add handler
596596 eventForDelegateType.Publish.AddHandler(
0 commit comments