Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please answer using ML, thank you in advance for the help! 18. Write a function point_of_json of type json -> point option. If the argument
Please answer using ML, thank you in advance for the help!
18. Write a function point_of_json of type json -> point option. If the argument is a json object that contains fields named "latitude" and "longitude", both of which are json numbers, then point_of_json returns Some p where p is the point represented by these coordinates. Otherwise, it returns None. Solution is 5 lines and uses dot and nested patterns. 19. Write a function filter_access_path_in_rect of type string list -> rect -> json list -> json list. The output should be a subset of the third argument, containing exactly those elements of the input list that (1) have a field available via the given access path, (2) that field's contents are a JSON object that can be converted to a point via point_of_json, and (3) the resulting point is within the rectangle specified by the second argument. Sample solution is less than 15 lines. 18. Write a function point_of_json of type json -> point option. If the argument is a json object that contains fields named "latitude" and "longitude", both of which are json numbers, then point_of_json returns Some p where p is the point represented by these coordinates. Otherwise, it returns None. Solution is 5 lines and uses dot and nested patterns. 19. Write a function filter_access_path_in_rect of type string list -> rect -> json list -> json list. The output should be a subset of the third argument, containing exactly those elements of the input list that (1) have a field available via the given access path, (2) that field's contents are a JSON object that can be converted to a point via point_of_json, and (3) the resulting point is within the rectangle specified by the second argument. Sample solution is less than 15 linesStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started