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.
Its not? There just arent big enough test cases to see a difference. Try
triangular 100000000 `shouldBe` 5000000050000000
for example.This comment is hidden because it contains spoiler information about the solution
| b = x
would be fine. Straight pattern matching is another possibility, but it's mostly a matter of taste.I wouldn't worry too much about any difference between
case
,if
and|
expressions and pattern matches. After desugaring, there's probably no appreciable difference anyway. I would be not at all surprised if most solutions generate exactly the same bytecode in the end.That being said, learn the syntax first, how to interpret the error messages as best you can - write clean code later, you can always refactor.
Haskell is about expressions, guards are just IF blocks, in general
would normally just be
Thanks for the feedback! I was using Codewars to help learn Haskell so I'm not surprised my solution isn't great. Is | b = x valid or do you have another suggestion. Thanks again.
b == True
is an antipattern.