Question: We need to write small function on list operations both provided by the standard library and useful utility functions. Language to be used - F#
We need to write small function on list operations both provided by the standard library and useful utility functions.
Language to be used - F#

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 #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)"//
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
