(Lights Out) The mechanics described in this exercise can be used to implement a game lights out. 1. Create a function flip val flip : bool array array -> int -> int -> bool array array = that given a bool matrix and two integers i; j. it negates the values (true!false, false!true) at location i; j in the matrix, as well negating the values on the (up to) 4 horizontally/vertically adjacent elements. 2. Create a function print matrix
OCAML programming
(Lights Out)
The
1. Create a function flip
val flip : bool array array -> int -> int -> bool array array = <fun>
that given a bool matrix and two integers i; j. it negates the values
(true!false, false!true) at location i; j in the matrix, as well negating
the values on the (up to) 4 horizontally/vertically adjacent elements.
2. Create a function print matrix
val print_matrix : bool array array -> unit = <fun>
that given a bool matrix, it prints it on screen (true !"T", false!"F").
Sample input:
# let matrix= [|[|false; true; true; false|]; [|true; false; false; true|];
[|false; false; true; true|]|];;
# print_matrix matrix;;
FTTF
TFFT
FFTT
# flip matrix 1 4;;
# print_matrix matrix;;
FTFT
TFFF
FFTT
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)