This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Buildings | |
// Needs Easy GIS from Nuget: https://www.nuget.org/packages/Huitian.EGIS.ShapeFileLib/ | |
// Also need to add a reference to System.Drawing | |
module Drawer = | |
open System | |
open System.Drawing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace OSBuildings | |
module Perimeter = | |
// Need to include this Nuget package: https://www.nuget.org/packages/Huitian.EGIS.ShapeFileLib/ | |
// Need to add a reference to System.Drawing | |
let shpPath = @"C:\Data\OSBuildings\wales_buildings_clipped.shp" | |
let demo1() = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if COMPILED | |
namespace CasualFSharp | |
#endif | |
module Monopoly = | |
open System | |
type Player = | |
| Boot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace CasualFSharp | |
module PatternMatching = | |
let describeInt i = | |
match i with | |
| 1 -> "One" | |
| 2 -> "Two" | |
| _ -> "Many" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let CumulativeDistribution (x : int) (n : int) (p : float) = | |
let EssentiallyZero = 10E-12 | |
let m = (float(n) * p) |> truncate |> int | |
let CalcCurrent value k = | |
if k > m then | |
value * float(n - k + 1) * p / (float(k) * (1. - p)) | |
else | |
value * float(k + 1) * (1. - p) / (float(n - k) * p) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (hand.Cards.[0].Rank) = Ace && (Consecutive hand.Cards) && (SameSuit hand.Cards) then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// The possible outcomes when comparing two Poker hands. | |
type Outcome = Win | Draw | Lose | |
with | |
static member FromRanks (rank1 : Rank) (rank2 : Rank) = | |
let sortValue1, sortValue2 = rank1.SortValue, rank2.SortValue | |
if sortValue1 > sortValue2 then | |
Win | |
elif sortValue1 < sortValue2 then | |
Lose | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Compare two hands, the first of which can Win, Draw or Lose against the second. | |
let CompareHands (hand1 : Hand) (hand2 : Hand) = | |
match hand1, hand2 with | |
| RoyalFlush, RoyalFlush -> | |
raise (ArgumentException("Impossible combination: two Royal Flushes")) | |
| RoyalFlush, _ -> Win | |
| _, RoyalFlush -> Lose | |
| StraightFlush, StraightFlush -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let (|FourOfAKind|_|) (hand : Hand) = | |
if (RankCounts hand.Cards).[0] = 4 then | |
FourOfAKind |> Some | |
else | |
None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let (|StraightFlush|_|) (hand : Hand) = | |
if (SameSuit hand.Cards) && (Consecutive hand.Cards) then | |
StraightFlush |> Some | |
else | |
None |
NewerOlder