Question: Use Ocaml Language. One important syntactic task of programming in most languages is making sure your parentheses match! Write a function parens that takes a
Use Ocaml Language.
One important syntactic task of programming in most languages is making sure your parentheses match! Write a function parens that takes a list of characters including open parens '(' and close parens ')'. It should return true if and only if all parentheses are correctly matched. Hints/additional specifications:
You will probably want a recursive helper function that scans the list left to right and tracks some additional information.
If you reach the end of the list and there are unmatched open parens, the parens are not matched.
If you see a close paren that doesn't match an open paren, the parens are not matched.
A list with no parentheses is considered correctly matched. You can ignore any characters other than '(' and ')'.
The Base code:
let parens (l: char list) : bool = raise ImplementMe ;;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
