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.
Why does this work? How do I write the same for, say, subtract?
Approved by someone
making them
static
is mostly a matter of good practice/self-documentation, as it is good practice not to expose more than was it necessary. functions that must bestatic
on the other hand (to prevent cheating) are the functions that make up the reference solution, if any, but you didnt need one for this translationIt is not too much of a problem that users can call
do_test()
, because beginners will likely not try that. Regarding whether to put it in preloaded, I have done this for many translations, precisely to avoid code duplication as you remarked. But I know that some other people do not like it, because it hides the calling code from the user.Nowadays I tend to put it in the tests files when it is simple enough (e.g. when it merely compares two
int
s, as opposed to arrays of strings or similar).It is up to you to decide.
Thanks, my bad.
Making them
static
does make them inaccessible, butdo_test()
is still accessible by the user and can end up in an infinite mutual recursion.Should I move
do_test()
into the separate tests (although that will introduce duplication)?That makes sense, thanks for reviewing it.
I have updated the translation now, I hope it is better.
i feel like (safely) concatenating two strings in C is a bit too difficult for a "fix-me" style 8-kyu kata. this kind of kata is intended for absolute beginners; they will not understand the initial code, even if they know the syntax for a function definition. perhaps the function should perform a simpler task like an addition instead ?
by the way, in C it is good practice to
const
-qualify a pointer passed in parameter when the function does not modify what it points to:I have added a translation for C; please review, thanks!