Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

We need to write 3 small functions on list operations both provided by the standard library and useful utility functions. Language to be used -

We need to write 3 small functions on list operations both provided by the standard library and useful utility functions.

Language to be used - F#

Urgent help, will give thumbs up and good feedback, thank you!

image text in transcribed

image text in transcribed

image text in transcribed

Exercise #17: isMatch str The isMatch function returns true if str has matching parentheses, and false otherwise. Parentheses are matched if the following conditions are true 1. The number of y's can not exceed the number of ( for any substring starting from the beginning 2. The number of ('s and )'s are equal at the end of the string You only need to check whether the left parentheses 'l' and the right parentheses ')' matches in str, and any other character in str is irrelevant to whether the parentheses match or not. A function stringToCharList is provided to translate the string into a char list to make it easier to parse/traverse with your algorithm. The is Match function should be written in the Project02-17.fs file. // // isMatch str // returns true if str has matching parentheses, and false otherwise // // Examples: // isMatch" => true isMatch "(" => false isMatch ")" => false isMatch "outer (middle({ true isMatch "outer (middle(inner})" => false // Exercise #18: firstMatch str The firstMatch function finds the FIRST pair of matching parentheses and returns the substring inside the parenthesis. The first pair is defined as the pair whose left parenthesis '(' appears first in the string, not whose right parenthesis ')' appears first. For example, when the input is input="krepe((choko) (kream))", the first left parenthesis is index[5] (counting from 0), and the matching right parenthesis is input[20], so the substring inside it is input[6..19]= ="(choko) (kream)". You can assume (isMatch str = true). A function stringToCharlist is provided to translate the string into a char list, in addition to a function charListToString to convert the resulting list you build back into a string. The firstMatch function should be written in the Project02-18.fs file. // // firstMatchs // returns a string containing the content within the first pair of matching parentheses // first means started first with a '('not ended first with a ')' // Examples: firstMatch firstMatch "()" => "" firstMatch "phrase (comment)" => "comment" // firstMatch "phrase (comment) Furthermore (details)" => "comment" // firstMatch "krepe((choko) (kream))" => "(choko) (kream)"// Exercise #19: all Matches str The allMatch function returns a list of all substrings inside all the parentheses, in the order they appear. You can assume (isMatch str = true). You might find firstMatch helpful as a starting point for this algorithm. The all Matches function should be written in the Project02-19.fs file. // // allMatches s // returns the content in the first pair of matching parentheses // // Examples: // allMatches". => [] // allMatches "()" => [""] // allMatches "phrase (comment)" => ["comment"] // allMatches "phrase (comment) Furthermore (details)" => ["comment"; "details"] // allMatches "krepe((choko(kream)))"=> // ["(choko(kream))"; "choko(kream)"; "kream"] allMatches "krepe((choko() (kream)))"=> ["(choko() (kream))"; "choko( ) (kream)"; ""; "kream" ] //

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

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

Students also viewed these Databases questions

Question

1. Signs and symbols of the map Briefly by box ?

Answered: 1 week ago

Question

Types of physical Maps?

Answered: 1 week ago

Question

Explain Intermediate term financing in detail.

Answered: 1 week ago

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago