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.
.
.
This comment is hidden because it contains spoiler information about the solution
asd
The line of code
const message = "Just throw like this!";
returns the errorError: I think you are cheating, your code have throw.
lol
This comment is hidden because it contains spoiler information about the solution
Good point. Resolved.
Shouldn't '[]' be removed in optimization?
I went ahead and edited ZahNarztiK's Javascript translation. It contained typo in solution (was checking
c
instead ofc[0]
). Also, added couple cases to test repetition of..
and,,
.asd
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. )
There is a relevant part in the hints section in the bottom. ;-)
"All test inputs are valid."
As mentioned,
List.iterate(inc, 0).last()
andList.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. Becauseconstant
isn't curried and evaluation is strict,constant
here is indistinguishable fromidentity
, but think of it asconst
, notid
.last
andreverse
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 overflowError
, 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.
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 whatfoldr
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...