SOLVE A TASK IN THE OCAML PROGRAMMING LANGUAGE :

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

SOLVE A TASK IN THE OCAML PROGRAMMING LANGUAGE :

Post by answerhappygod »

SOLVE A TASK IN THE OCAML PROGRAMMING LANGUAGE
:
Solve A Task In The Ocaml Programming Language 1
Solve A Task In The Ocaml Programming Language 1 (124.43 KiB) Viewed 60 times
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.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply