A bit of productionising

This commit is contained in:
Smaug123
2023-01-16 13:43:16 +00:00
parent b3c3978afa
commit 9697bb5311
9 changed files with 86 additions and 106 deletions

20
Reactivation/Seq.fs Normal file
View File

@@ -0,0 +1,20 @@
namespace Reactivation
[<RequireQualifiedAccess>]
module Seq =
let minMax (s : int seq) : struct (int * int) voption =
use e = s.GetEnumerator ()
if not (e.MoveNext ()) then ValueNone else
let mutable min = e.Current
let mutable max = e.Current
while e.MoveNext () do
if e.Current < min then min <- e.Current
if e.Current > max then max <- e.Current
ValueSome (struct (min, max))
let rangeOrZero (s : int seq) : int =
match minMax s with
| ValueNone -> 0
| ValueSome (min, max) -> max - min