I have some elixir code I am using to score a ping pong game. Since I am new to functional programming I was hoping there might be a more elegant solution to this.This part of the code is used in a GenServer to check if the next point could result in a win. So that means will the leading players next point meet the minimum score requirement (11 or 21 in ping pong) and also be 2 points in front of the other play.Anyone got a better idea here?def handle_call(:next_point_wins, _from, game) do#game.score = [10,5]nextPlayer1 = List.first(game.score) + 1nextPlayer2 = List.last(game.score) + 1scoreDifference =  case nextPlayer1 > nextPlayer2 do    true      ->      leader = nextPlayer1      nextPlayer1 - nextPlayer2    false      ->      leader = nextPlayer2      nextPlayer2 - nextPlayer1  endcond do  scoreDifference + 1 >= 2 and leader >= game.winningScore    ->      IO.puts SOMEONE IS ABOUT TO WIN      {:reply, :ok, game}  true     ->       IO.puts NO-ONE IS ABOUT TO WIN      {:reply, :ok, game}endend
Scoring Ping Pong in Elixir
beginner;elixir