Files
advent-of-code-2023/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Lib/Direction.fs
patrick 16b801f267
All checks were successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/all-checks-complete Pipeline was successful
Pull out bits from day 18 (#20)
Co-authored-by: Smaug123 <patrick+github@patrickstevens.co.uk>
Reviewed-on: #20
2023-12-23 21:35:10 +00:00

25 lines
576 B
Forth

namespace AdventOfCode2023
type Direction =
| Left = 0
| Right = 1
| Up = 2
| Down = 3
module Direction =
let inline toUInt (d : Direction) =
match d with
| Direction.Left -> 0us
| Direction.Right -> 1us
| Direction.Up -> 2us
| Direction.Down -> 3us
| _ -> failwith "Bad"
let inline ofChar (c : char) : Direction =
match c with
| 'L' -> Direction.Left
| 'R' -> Direction.Right
| 'U' -> Direction.Up
| 'D' -> Direction.Down
| c -> failwith $"Bad: %c{c}"