Ad
  • Default User Avatar

    Why does this work? How do I write the same for, say, subtract?

  • Custom User Avatar

    Approved by someone

  • Default User Avatar

    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 be static 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 translation

    It 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 ints, as opposed to arrays of strings or similar).

    It is up to you to decide.

  • Default User Avatar

    Thanks, my bad.

    Making them static does make them inaccessible, but do_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)?

  • Default User Avatar

    That makes sense, thanks for reviewing it.

    I have updated the translation now, I hope it is better.

  • Default User Avatar

    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:

    char *concat (const char *verb, const char *noun)
    
  • Default User Avatar

    I have added a translation for C; please review, thanks!