
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Ocaml Help
![1 Pipe matrix
You are given the type
type pipe=
LeftRight | UpDown | DownRight | DownLeft Up
Right UpDownRight | DownLeftRight;;
Each of the cases represent one of the following characters (in
the same order):
let chars=[ |"\u{02550}";"\u{02551}";"\u{0255
4}";"\u{02557}";"\u{0255A}";
"\u{02560}"; "\u{02566}"|]; ;
Note that these wont print via print_string in older OCaml
versions, but they work in https://try.ocamlpro.com/.
a. Write a function \(\verb+getleaks: pipe array array -> (int
*
int) list = <fun>+\) whose input is a rectangular pipe
matrix. The pipe at (0,0) has flow and spreads it through
the neighboring pipes if the corresponding pipes match /
characters visually match. Note that the lack of an
"UpLeft" piece implies there are no cycles and the flow
can essentially only move right or down, however it can
split into multiple streams. The functions should print the
original matrix via the corresponding characters, followed
by printing the pipes with flow, replacing pipes without
flow with \(\verb+"\u{2588}"+\). A leak happens at (i,j), if a
pipe at (i,j) has flow and attempts to spread it to a
neighboring pipe that cannot receive flow from such
direction (disregarding pipes that exit the matrix). Return
the locations of leaks as a list of pairs (in any order).](https://content.bartleby.com/qna-images/question/be5d5f71-3ad7-4161-bd6e-fd06ac1f44bb/25e10fa4-d62f-440e-b5c4-07b1e08a0591/7gte8b_thumbnail.jpeg)
Transcribed Image Text:1 Pipe matrix
You are given the type
type pipe=
LeftRight | UpDown | DownRight | DownLeft Up
Right UpDownRight | DownLeftRight;;
Each of the cases represent one of the following characters (in
the same order):
let chars=[ |"\u{02550}";"\u{02551}";"\u{0255
4}";"\u{02557}";"\u{0255A}";
"\u{02560}"; "\u{02566}"|]; ;
Note that these wont print via print_string in older OCaml
versions, but they work in https://try.ocamlpro.com/.
a. Write a function \(\verb+getleaks: pipe array array -> (int
*
int) list = <fun>+\) whose input is a rectangular pipe
matrix. The pipe at (0,0) has flow and spreads it through
the neighboring pipes if the corresponding pipes match /
characters visually match. Note that the lack of an
"UpLeft" piece implies there are no cycles and the flow
can essentially only move right or down, however it can
split into multiple streams. The functions should print the
original matrix via the corresponding characters, followed
by printing the pipes with flow, replacing pipes without
flow with \(\verb+"\u{2588}"+\). A leak happens at (i,j), if a
pipe at (i,j) has flow and attempts to spread it to a
neighboring pipe that cannot receive flow from such
direction (disregarding pipes that exit the matrix). Return
the locations of leaks as a list of pairs (in any order).
![getleaks pl ;;
1}}}
===
- : (int * int) list = [(1, 0); (1, 2); (3, 5);
(1, 5)]
getleaks p2 ;;
ל ל י
=H
- : (int * int) list = [(3, 3); (2, 2); (1, 1);
(2, 3); (0, 2)]](https://content.bartleby.com/qna-images/question/be5d5f71-3ad7-4161-bd6e-fd06ac1f44bb/25e10fa4-d62f-440e-b5c4-07b1e08a0591/k73q32k_thumbnail.jpeg)
Transcribed Image Text:getleaks pl ;;
1}}}
===
- : (int * int) list = [(1, 0); (1, 2); (3, 5);
(1, 5)]
getleaks p2 ;;
ל ל י
=H
- : (int * int) list = [(3, 3); (2, 2); (1, 1);
(2, 3); (0, 2)]
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps

Knowledge Booster
Similar questions
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education