Advertisement
ptrelford

Tennis Kata

Apr 18th, 2012
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 0.36 KB | None | 0 0
  1. -module(kata).
  2. -export([call/2]).
  3.  
  4. point(0) -> love;
  5. point(1) -> 15;
  6. point(2) -> 30;
  7. point(3) -> 40.
  8.  
  9. call(S,R) when S>=3,R>=3 ->
  10.  case S-R of
  11.    2  -> {game,server};
  12.    1  -> {adv,server};
  13.    0  -> deuce;
  14.    -1 -> {adv,receiver};
  15.    -2 -> {game,receiver}
  16.  end;
  17. call(4,_) -> {game,server};
  18. call(_,4) -> {game,receiver};
  19. call(S,R) -> {point(S),point(R)}.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement