Ad
  • Custom User Avatar

    This kata relies on parsing a function's source code and does not have well-defined requirements, and can't possibly. Function parameters can contain arbitrary JavaScript code whose handling would require writing an entire JavaScript parser:

    function pathologicalExample(
      arg1 = " a comma: , ",
      arg2 /* another comma: , */,
      arg3 = function nestedFunction(a, b) {},
      [arg4, arg5] = ['destructuring', 'parameters'],
      ...restParameters) {
    }
    
  • Custom User Avatar
  • Custom User Avatar

    TypeScript translation (literal translation of JavaScript; author inactive)

  • Custom User Avatar
  • Custom User Avatar
  • Custom User Avatar

    No random tests.

  • Custom User Avatar

    Haskell sample tests don't even compile without any modification to the code.

    Server Execution Error:
    The name of the test module must end with 'Spec'
    

    Adding Spec to the module name later fails with:

    test/Codewars/Kata/AllNoneAny/TestSpec.hs:25:5: error:
        • Couldn't match type ‘Arg a0’ with ‘()’
          Expected type: SpecWith ()
            Actual type: SpecWith (Arg a0)
          The type variable ‘a0’ is ambiguous
        • In a stmt of a 'do' block:
            it "shouldn't use any forbidden modules or functions"
              $ do hidden
                     [FromModule "Prelude" "any", FromModule "Prelude" "all", ....]
          In the second argument of ‘($)’, namely
            ‘do it "shouldn't use any forbidden modules or functions"
                  $ do hidden [...]’
          In a stmt of a 'do' block:
            describe "hidden modules"
              $ do it "shouldn't use any forbidden modules or functions"
                     $ do hidden [...]
       |
    25 |     it "shouldn't use any forbidden modules or functions" $ do
       |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
       
    
  • Custom User Avatar

    No random tests.

  • Custom User Avatar

    No random tests.

  • Custom User Avatar

    ( JS, haven't really checked Haskell )

    Testing is ++BAD. This solution is two thirds wrong, but it passes.

    What's wrong with that solution and with the tests is left as an exercise for the author.

  • Custom User Avatar

    Needs random test cases

  • Custom User Avatar

    Some extra tests in Haskell, translated from the ones that @jmjjg created in JavaScript:

    describe "empty arrays" $ do
      it "An empty array has not all elements greater than zero" $ do
        A.all (>0) []   `shouldBe` False
      it "An empty array has not any element greater than zero" $ do
        A.any (>0) []   `shouldBe` False
      it "An empty array has none element greater than zero" $ do
        A.none (>0) []   `shouldBe` True
      it "An empty array has not all elements lower or equal than zero" $ do
        A.all (<=0) []   `shouldBe` False
      it "An empty array has not any element lower or equal than zero" $ do
        A.any (<=0) []   `shouldBe` False
      it "An empty array has none element greater or equal than zero" $ do
        A.none (<=0) []   `shouldBe` True
    
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Concerning a Haskell translation: the current version of the kata uses an array, but in Haskell a tuple would be more idiomatic:

    gimme :: Ord a => (a, a, a) -> Int
    

    However, the Haskell translation would then differ from the JavaScript/Python variant, since it doesn't use arrays/lists. That being said, I would use the more correct tuple variant instead of a list.

  • Loading more items...