This file contains 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
open Microsoft.FSharp.Data.UnitSystems.SI.UnitNames | |
type Supply = Supply of float<watt> | |
let Supply (electricity: float<watt>) = | |
if electricity > 0.0<watt> then | |
Some (Supply electricity) | |
else | |
None |
This file contains 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
type Transmit = Station -> Station -> Supply option -> Station * Station | |
let transmit (fStation: Station) (tStation: Station) (supply: Supply option) = | |
match fStation, tStation, supply with | |
| PowerStation fStation, TransmissionSubstation tStation, Some (Supply supply) -> | |
match fStation.Supply, tStation.Supply with | |
| Some (Supply fStationSupply), Some (Supply tStationSupply) -> | |
if fStationSupply > supply then | |
PowerStation { fStation with Supply = Supply (fStationSupply - supply) }, | |
TransmissionSubstation { tStation with Supply = Supply (tStationSupply + supply) } |