Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer using ML, thank you in advance for the help! 14. Write a function count_occurrences of type string list -> exn -> (string *

Please answer using ML, thank you in advance for the help!

image text in transcribed

14. Write a function count_occurrences of type string list -> exn -> (string * int) list. If the string list argument is sorted (using OCaml's built-in comparison operator, (json list) -> string list (the parentheses in this type are optional, so the REPL won't print them). For any object in the json list that has a field available via the given access path (string list), and has contents that are a JSON string (e.g., String "hi") put the contents string (e.g., "hi") in the output list (order does not matter; the output should have duplicates when appropriate). Sample solution is 6 lines thanks to dots. 16. Write a function filter_access_path_value of type string list -> string -> json list -> json list. The output should be a subset of the third argument, containing exactly those elements of the input list that have a field available via the given access path, and that field's contents are a JSON string equal to the second argument. Sample solution uses dots and is less than 10 lines. 17. Some of the bus data uses latitude and longitude positions to describe the location of vehicles in real time. To narrow our focus onto a particular geographical area, we will use the record types rect and point, which represent a rectangle and a point, respectively. The types are defined in the starter code, but copied here for completeness. type rect { min_latitude: float; max_latitude: float; min_longitude: float; max_longitude: float } { latitude: float; longitude: float } type point Write a function in_rect of type rect -> point -> bool that determines whether a given point falls inside a given rectangle (inclusive). Solution is two lines and uses a lot of conjunction (&&). 14. Write a function count_occurrences of type string list -> exn -> (string * int) list. If the string list argument is sorted (using OCaml's built-in comparison operator, (json list) -> string list (the parentheses in this type are optional, so the REPL won't print them). For any object in the json list that has a field available via the given access path (string list), and has contents that are a JSON string (e.g., String "hi") put the contents string (e.g., "hi") in the output list (order does not matter; the output should have duplicates when appropriate). Sample solution is 6 lines thanks to dots. 16. Write a function filter_access_path_value of type string list -> string -> json list -> json list. The output should be a subset of the third argument, containing exactly those elements of the input list that have a field available via the given access path, and that field's contents are a JSON string equal to the second argument. Sample solution uses dots and is less than 10 lines. 17. Some of the bus data uses latitude and longitude positions to describe the location of vehicles in real time. To narrow our focus onto a particular geographical area, we will use the record types rect and point, which represent a rectangle and a point, respectively. The types are defined in the starter code, but copied here for completeness. type rect { min_latitude: float; max_latitude: float; min_longitude: float; max_longitude: float } { latitude: float; longitude: float } type point Write a function in_rect of type rect -> point -> bool that determines whether a given point falls inside a given rectangle (inclusive). Solution is two lines and uses a lot of conjunction (&&)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago