Last active
February 3, 2022 17:29
-
-
Save matthewcrews/b7928c8d7232df2b16adc42c99cca27b to your computer and use it in GitHub Desktop.
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
[<Measure>] type Chicken | |
[<Measure>] type Cow | |
type Arr<[<Measure>] 'Measure>(v: array<_>) = | |
let values = v | |
member _.Item | |
with inline get (i: int<'Measure>) = | |
v.[int i] | |
member _.GetSlice (start, finish) = | |
let start = defaultArg start 0<_> |> int | |
let finish = defaultArg finish (1<_> * (v.Length - 1)) |> int | |
values[start .. finish] | |
|> Arr<'Measure> | |
let chickenSizeArray = | |
[|1.0 .. 10.0|] | |
|> Arr<Chicken> | |
let chickenSlice = chickenSizeArray[0<Chicken> .. 2<Chicken>] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment