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

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

  • Default User Avatar
  • Custom User Avatar

    The line of code const message = "Just throw like this!"; returns the error Error: I think you are cheating, your code have throw.

  • Default User Avatar
  • Custom User Avatar

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

  • Default User Avatar

    Good point. Resolved.

  • Default User Avatar

    Shouldn't '[]' be removed in optimization?

  • Custom User Avatar

    I went ahead and edited ZahNarztiK's Javascript translation. It contained typo in solution (was checking c instead of c[0]). Also, added couple cases to test repetition of .. and ,,.

  • Custom User Avatar
  • Custom User Avatar

    That is actually not the intended way to pass that test, no.

    I have mixed feelings to hear you are struggling. I sincerely hope it's not too frustrating. I did intend to challenge people though, and I am happy to hear that seems to be working. :P I did not dare set a ranking myself, but I am happy with what has to be Voile's. :]

    But if the problem is confusing, or really too little, specification, please let me know.

    Meanwhile, take the hint Voile mentioned. It's for this test exactly.

    Aside: I have a kata specifically on foldr in the pipeline. That one might actually be a nice workup towards this kata. It'll be too late for you (sorry), but it might help other people when it's published; at least you should have less problems with that one after you've solved this one. It's a fun one! :]

    Voile, you haven't seen this kata's part II yet! There is .. and it's more challenging .. but I would like some solutions on this one first. ( It's still a draft kumite, not yet a draft kata. )

  • Custom User Avatar

    There is a relevant part in the hints section in the bottom. ;-)

  • Custom User Avatar

    "All test inputs are valid."

    As mentioned, List.iterate(inc, 0).last() and List.repeat(3).reverse().head() are not tested. List.iterate(inc, 0).foldr(identity) isn't either - List.iterate(inc, 0).foldr(constant) is. There is a subtle difference. Because constant isn't curried and evaluation is strict, constant here is indistinguishable from identity, but think of it as const, not id.

    last and reverse both specify "diverges for infinite list", which means the value is undefined. You can return anything you like, including blowing up the Universe. Generally, diverging values are to be expected to throw a stack overflow Error, this is the real world after all, but this is not tested: see above.

    Should I specify more clearly what is implied by "diverges" ? This is a work in progress still, after all.

  • Custom User Avatar

    You can't reverse or take the last element of an infinite List, so they won't appear in the tests.

    As for the second, 0. That's what foldr has to do/check in addition to being a lazy list operation.

    As usual, this whole kata is heavily inspired by the List type in Haskell, so it's instructive to look at how list operations behave there.

  • Loading more items...