SOLVE A TASK IN THE OCAML PROGRAMMING LANGUAGE
:
2 Settlers of Catan You are given the following custom types 1 # type player= Orange | Red | Blue | White ; ; 2 # type piece= Knight of player| Town of player | City of player | Road of player | Wool of player | Brick of player | Lumber of player | Grain of player | Ore of player;; All four players pieces are stored in a single piece array. Write functions (a) getplayer : piece -> player = <fun> that given a piece, it returns the player that owns it. (b) filterbyplayer : player -> piece array -> piece array = <fun> that given a player and a piece array, it returns the subarray containing pieces that belong to that player. (c) countpoints : player -> piece array -> int = <fun> that given a player and a piece array, it returns the points a player has. Points are computed as follows: Each Town owned by the player is worth 1 point and each City owned by the player is worth 2 points. An additional 2 points are awarded if the player owns at least 5 Road pieces, and an additional 2 points are awarded if the player owns at least 3 Knight pieces.
SOLVE A TASK IN THE OCAML PROGRAMMING LANGUAGE :
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
SOLVE A TASK IN THE OCAML PROGRAMMING LANGUAGE :
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!