Skip to content

Commit

Permalink
add Direction.opposite
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed Jan 10, 2020
1 parent 6b8462f commit f5485d9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Direction.elm
@@ -1,4 +1,4 @@
module Direction exposing (Direction, down, left, move, right, up)
module Direction exposing (Direction, down, left, move, opposite, right, up)


type alias Direction =
Expand All @@ -25,6 +25,11 @@ right =
( 0, 1 )


opposite : Direction -> Direction
opposite ( row, column ) =
( -row, -column )


move : { row : Int, column : Int } -> Direction -> { row : Int, column : Int }
move { row, column } ( adjRow, adjCol ) =
{ row = row + adjRow
Expand Down

0 comments on commit f5485d9

Please sign in to comment.