-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved solution for smelodesousa/F5/5-brackets #40
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @zazedd !
The new solution is indeed better! as it's more concise and without non-exhaustive pattern-matching.
However, it seems there's a new corner case: if text = [')'; '(']
then the parentheses are unexpectedly accepted.
Do you think this code would be better?
let verify text =
List.fold_left
(fun acc c -> if acc < 0 then acc else match c with '(' -> acc + 1 | ')' -> acc - 1 | _ -> acc)
0 text
= 0
If yes, feel free to add another test in test.ml; and maybe, rephrase a bit more the descr.md so that the question does not impose a unique solution.
E.g. "… has well-placed parentheses. If you are not familiar with list iterators, feel free to write a local function involving an accumulator …"
WDYT?
That totally went over my head! |
Thanks a lot @zazedd ! FYI the first CI job failed with this error:
Maybe, could you try changing |
Really sorry about the hold-up. |
No worries @zazedd ! BTW @AltGr I'm puzzled by the failure to build current learn-ocaml-corpus as is with learn-ocaml's master here: There is a bunch of
|
The solution for F5/5-brackets was over complicated and had some errors: