The wide mouth frog is particularly interested in the eating habits of other creatures.
He just can't stop asking the creatures he encounters what...
For further actions, you may consider blocking this person and/or reporting abuse
Haskell
I see you are learning about Haskell. Congratulations! This isn't an easy language to handle (I'm am myself a learner, but aren't we all?).
I guess in your solution, cases like
"ALLIGATOR"
and"aLlIgAtOr"
won't match the first pattern and will return"wide"
. But the OP was mentioning that the"alligator"
animal was case insensitive.So I'm proposing this solution.
I took the opportunity to handle the cases where there was too much spaces (as I did in my TypeScript proposal).
This may not be the final solution, or prone to enhancement, but I guess it is a good one. We can make it better together as a community!
Am I missing something here or is this really not a challenge at all?
Challenge or not, at this time there are 6 solutions posted here, and (I believe) only 2 are completely to spec.
Most seem legit to me... Maybe a typo here and there...
and not handling case insensitivity.
F#:
But that uses an active pattern to make it case insensitive, like this;
Active Patterns provide a real nice way to move the ugly details of the case insensitive comparison out the the way.
Well, I guess in this case it's down to personal preference and style.
I think that the length of String.Equals call detracts from comprehending what the code is doing, so moving it elsewhere is achieves more than just adding a layer of indirection.
I'm also not against using match over a simple bool- I quite like the kind of tabular layout of the code.
TypeScript
JS
Swift :
Good example of why unit tests are important!
Thanks a lot for this useful input, that's a good example of why constructive criticism is important.
Sorry. You nailed it, but misspelled alligator.
In Go.
The animal isn't case insensitive in your code
mounth_size('aLlIgAtOr')
will return'wide'
while it should return'small'
Ruby:
Maybe, I don't write a lot of Haskell so I couldn't say.