anchor.diff:      /// all the days of the year.
       let daysList = 
           [ for month in 1 .. 12 do
  -              for day in 1 .. System.DateTime.DaysInMonth(2012, month) do 
  +              for day in 1 .. System.DateTime.DaysInMonth(2017, month) do 
                     yield System.DateTime(2012, month, day) ]
  +
  +    // Print the first 5 elements of 'daysList' using 'List.take'.
  +    printfn "The first 5 days of 2017 are: %A" (daysList |> List.take 5)
   
       /// Computations can include conditionals.  This is a list containing the tuples
       /// which are the coordinates of the black squares on a chess board.
  
positive.code: // For additional templates to use with F#, see the 'Online Templates' in Visual Studio, 
  //     'New Project' --> 'Online Templates'
  
  
  // Open namespaces using 'open'
  open System
  
  
  /// First some basics on integers and numbers
  module IntegersAndNumbers = 
  
      /// This is a sample integer.
  
negative.code:     /// This example prints all the cards in a playing deck.
      let printAllCards() = 
          for card in fullDeck do 
              printfn "%s" (showPlayingCard card)
  
      // Single-case DUs are often used for domain modeling.  This can buy you extra type safety
      // over primitive types such as strings and ints.
      //
      // Single-case DUs cannot be implicitly converted to or from the type they wrap.
      // For example, a function which takes in an Address cannot accept a string as that input,
      // or vive/versa.
      type Address = Address of string
      type Name = Name of string
      type SSN = SSN of int
  
      // You can easily instantiate a single-case DU as follows.
      let address = Address "111 Alf Way"
      let name = Name "Alf"
      let ssn = SSN 1234567890
  
      /// When you need the value, you can unwrap the underlying value with a simple function.
      let unwrapAddress (Address a) = a
      let unwrapName (Name n) = n
      let unwrapSSN (SSN s) = s
  
      // Printing single-case DUs is simple with unwrapping functions.
      printfn "Address: %s, Name: %s, and SSN: %d" (address |> unwrapAddress) (name |> unwrapName) (ssn |> unwrapSSN)
  
      /// Disciminated Unions also support recursive definitions.
      ///
      /// This represents a Binary Search Tree, with one case being the Empty tree,
      /// and the other being a Node with a value and two subtrees.
      type BST<'T> =
          | Empty
          | Node of value:'T * left: BST<'T> * right: BST<'T>
  
      /// Check if an item exists in the binary search tree.
      /// Searches recursively using Pattern Matching.  Returns true if it exists; otherwise, false.
      let rec exists item bst =
          match bst with
          | Empty -> false
          | Node (x, left, right) ->
              if item = x then true
              elif item < x then (exists item left) // Check the left subtree.
              else (exists item right) // Check the right subtree.
  
      /// Inserts an item in the Binary Search Tree.
      /// Finds the place to insert recursively using Pattern Matching, then inserts a new node.
      /// If the item is already present, it does not insert anything.
      let rec insert item bst =
          match bst with
          | Empty -> Node(item, Empty, Empty)
          | Node(x, left, right) as node ->
              if item = x then node // No need to insert, it already exists; return the node.
              elif item < x then Node(x, insert item left, right) // Call into left subtree.
              else Node(x, left, insert item right) // Call into right subtree.
  
      /// Discriminated Unions can also be represented as structs via the 'Struct' attribute.
      /// This is helpful in situations where the performance of structs outweighs
      /// the flexibility of reference types.
      ///
      /// However, there are two important things to know when doing this:
      ///     1. A struct DU cannot be recursively-defined.
      ///     2. A struct DU must have unique names for each of its cases.
      [<Struct>]
      type Shape =
          | Circle of radius: float
          | Square of side: float
          | Triangle of height: float * width: float
  
  
  /// Pattern Matching is a feature of F# that allows you to utilize Patterns,
  /// which are a way to compare data with a logical structure or structures, 
  /// decompose data into constituent parts, or extract information from data in various ways.
  /// You can then dispatch on the "shape" of a pattern via Pattern Matching.
  /// 
  /// To learn more, see: https://docs.microsoft.com/en-us/dotnet/articles/fsharp/language-reference/pattern-matching
  module PatternMatching =
  
      /// A record for a person's first and last name
      type Person = {
          First : string
          Last  : string
      }
  
      /// A Discriminated Union of 3 different kinds of employees
      type Employee =
          | Engineer of engineer: Person
          | Manager of manager: Person * reports: List<Employee>
          | Executive of executive: Person * reports: List<Employee> * assistant: Employee
  
      /// Count everyone underneath the employee in the management hierarchy,
      /// including the employee.
      let rec countReports(emp : Employee) =
          1 + match emp with
              | Engineer(id) ->
                  0
              | Manager(id, reports) ->
                  reports |> List.sumBy countReports
              | Executive(id, reports, assistant) ->
                  (reports |> List.sumBy countReports) + countReports assistant
  
  
      /// Find all managers/executives named "Dave" who do not have any reports.
      /// This uses the 'function' shorthand to as a lambda expression.
      let rec findDaveWithOpenPosition(emps : List<Employee>) =
          emps
          |> List.filter(function
                         | Manager({First = "Dave"}, []) -> true // [] matches an empty list.
                         | Executive({First = "Dave"}, [], _) -> true
                         | _ -> false) // '_' is a wildcard pattern that matches anything.
                                       // This handles the "or else" case.
  
      open System
  
      /// You can also use the shorthand function construct for pattern matching, 
      /// which is useful when you're writing functions which make use of Partial Application.
      let private parseHelper f = f >> function
          | (true, item) -> Some item
          | (false, _) -> None
  
      let parseDateTimeOffset = parseHelper DateTimeOffset.TryParse
  
      let result = parseDateTimeOffset "1970-01-01"
      match result with
      | Some dto -> printfn "It parsed!"
      | None -> printfn "It didn't parse!"
  
      // Define some more functions which parse with the helper function.
      let parseInt = parseHelper Int32.TryParse
      let parseDouble = parseHelper Double.TryParse
      let parseTimeSpan = parseHelper TimeSpan.TryParse
  
      // Active Patterns are another powerful construct to use with pattern matching.
      // They allow you to partition input data into custom forms, decomposing them at the pattern match call site. 
      //
      // To learn more, see: https://docs.microsoft.com/en-us/dotnet/articles/fsharp/language-reference/active-patterns
      let (|Int|_|) = parseInt
      let (|Double|_|) = parseDouble
      let (|Date|_|) = parseDateTimeOffset
      let (|TimeSpan|_|) = parseTimeSpan
  
      /// Pattern Matching via 'function' keyword and Active Patterns often looks like this.
      let printParseResult = function
          | Int x -> printfn "%d" x
          | Double x -> printfn "%f" x
          | Date d -> printfn "%s" (d.ToString())
          | TimeSpan t -> printfn "%s" (t.ToString())
          | _ -> printfn "Nothing was parse-able!"
  
      // Call the printer with some different values to parse.
      printParseResult "12"
      printParseResult "12.045"
      printParseResult "12/28/2016"
      printParseResult "9:01PM"
      printParseResult "banana!"
  
  
  /// Option values are any kind of value tagged with either 'Some' or 'None'.
  /// They are used extensively in F# code to represent the cases where many other
  /// languages would use null references.
  ///
  /// To learn more, see: https://docs.microsoft.com/en-us/dotnet/articles/fsharp/language-reference/options
  module OptionValues = 
  
      /// First, define a zipcode defined via Single-case Discriminated Union.
      type ZipCode = ZipCode of string
  
      /// Next, define a type where the ZipCode is optionsl.
      type Customer = { ZipCode: ZipCode option }
  
      /// Next, define an interface type the represents an object to compute the shipping zone for the customer's zip code, 
      /// given implementations for the 'getState' and 'getShippingZone' abstract methods.
  