Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
You are right on the necessary of keeping both parensToTree and treeToParens test. Then my only problem would be droping "" test in the parensToTree part. This will make two test parts totally sysmetry (3 lines t0 3 lines).
Thank you for this nice kata, anyway.
"you still have to deal with all strings"--> We are asked to encode "balanced parentheses", not random string input right? The description claims: "Binary trees can be encoded as strings of balanced parentheses". So, we expect the input should be balanced parentheses. Empty string "" is arguable to be balanced parentheses. Of course, "" could be included as valid input. My point is whether to encode "" to trees should be left optional to people.
The empty string "" test case should be drop. Enforce this edge case implies solution had to map "" to Leaf.
As a counter example, I find maping () to a leaf, and (()()) to leaf :*: leaf is quit reasonable and should be a valid solution.
How about keeping only the ---parensToTree (treeToParens Tree)--- test cases. This will be enough to cover all possible string presentation.
Haskell version raised error:
"Data constructor not in scope: Number :: (p0 -> p1 -> p1) -> Number"
So, am I not supposed use Number constructor in the code?