Skip to content

Commit

Permalink
Iterate on go in Gleam
Browse files Browse the repository at this point in the history
  • Loading branch information
Sgoettschkes committed Oct 5, 2023
1 parent 024cf1b commit 23a5a6b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions gleam/go/src/go.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,19 @@ pub fn apply_rules(
let res =
game
|> rule1()
|> result.map(fn(x) { rule2(x) })
|> result.try(fn(x) { rule3(x) })
|> result.try(fn(x) { rule4(x) })
|> result.map(rule2)
|> result.try(rule3)
|> result.try(rule4)

case res {
Ok(g) ->
case g.player {
Black -> Game(..g, player: White)
White -> Game(..g, player: Black)
}
Ok(g) -> change_player(g)
Error(err) -> Game(..game, error: err)
}
}

fn change_player(game: Game) {
case game.player {
Black -> Game(..game, player: White)
White -> Game(..game, player: Black)
}
}

0 comments on commit 23a5a6b

Please sign in to comment.