7 kyu
Map over a list of lists
110 of 2,183Paul Robertson
Loading description...
Fundamentals
Lists
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
JS -> the original array shouldn't be mutated.
This comment has been hidden.
I'm trying to learn Java and came across this kata. I was daunted by the syntax in the problem which I had never seen before. But I sat down, looked up the unknowns bit by bit, trying to understand what the problem was asking and how I might solve it.
Despite my best efforts I couldn't get anywhere close. Not just a bad solution, or a partial one, I simply couldn't write an answer which even ran. I know a little bit more about Function, lambda, and generics, but my confidence kinda took a hit.
Maybe this kata is totally misranked and should be much higher, or it just needs more explanation, or I'm a complete idiot. It could be the latter, I'm willing to admit that, but it feels like something is off with this kata.
Well, just tried it in Python and it was super easy.
It's just one step ahead of this one. Maybe you should try it first in Java.
No, you are not a complete idiot. It's the kata which is very misleading. Consider this example code:
Note how the
cast(...)
method can be compared to what agridMap(...)
implementation is supposed to do. I hope this helps.I wrote the original kata in Haskell. The syntax for the function declaration and definition in Haskell is much simpler than in Java.
In fact some people considered the Haskell kata too trivial to be approved.
Wow, a nice example of how much difference the choice of programming language can make. Thanks for the explanation. So I'm going to correct myself: It's not the kata. But it's the Java translation (or the language itself) which makes things very difficult.
Very poor description. Basically it ask you to map 'xss' with 'fn' condition.
Agree. I find that the descriptions on a lot of the code challenges lacking. Spend more time trying to work out what the question is rather than finding a solution. Glad it wasn't just me trying ot figure out what to do.
Ruby: is it possible to add a custom error message that includes the input?
Sorry, was my first translation and I'm not that well versed with Ruby, let alone RSpec.
Nevertheless, I was able to add custom error messages that include the list input. Not sure what the best course of action is for the blocks.
resolved
This comment has been hidden.
That is how the python tests already work, or what language are you meaning?
This comment has been hidden.
This kata reminds me why I favour C# over Java.
And yet you still insist on doing both
I swing both ways.
Have you seen the elegance of idiomatic Haskell solutions?
That is what "functions are first class citizens" should mean.
nice one..thank you
The Java initial solution signature is wrong.
Should be
done
This comment has been hidden.
are you mutating the input?
Yes. That was the problem. Thank you!
OP solved it, closing
JavaScript translation
Approved, thanks.
Trivial map/filter/reduce is not a novel kata idea.
Closing for approval.
If you feel a pressing need, you can reopen the issue afterwards.
Wouldn't ".. which maps a function over the lists in a list" be more correct?
If I read the current description literally, I should apply the function to the outer list, not map it over the inner lists.
Yes, that's clearer.
Aaaaaaaaaaaaaaaaaand my translation has a merge conflict. :O
Thanks for the quick reaction, and I'll prefork it with the updated description.
Python translation kumited
Approved, thanks.
Trivial map/filter/reduce is not a novel kata idea.
I agree it's trivial. I wrote the kata because for a Haskell beginner I think it provides an insight into the power of function composition.
I don't think it's going to get unpublished Alex.
Closing.
There are some suggestions for the tests in this fork. Readability really is a thing for tests - some day, someone ( and that someone might be you! ) might have to maintain that code.
( My vote is actually not because of that; I just think the subject matter is mighty thin to make a kata out of. My perspective on that may be skewed; that'll average out with other opinions then. )
I haven't found a duplicate of mapping lists inside a list. This could be a fun kyu8 to translate in all possible languages for beginners to solve.
For an 8 kyu, yes. But this is probably not going to be 8 kyu.
Thanks for your comments. I must try to learn to love writing the tests.
Writing tests for any kata can be like solving a 1 kyu kata, and sometimes harder. If it isn't a labour of love, you may want to stick to solving kata. There's often quite a lot to it really. :]
Writing descriptions, much the same. I guess you could try to outsource parts if you really don't like them? Because it's worth doing everything well on a new kata.