Open dpsanders opened 4 years ago
Thanks for the comment.
We do agree that returning the vector of iterates is better than printing them out inside a function. The best practice for this is (probably) to allocate an empty vector before the while
loop. However, for the case of the Collatz conjecture, we wouldn't know in advance how long the vector of iterates is.
Another thing to consider is where this chapter will come in. It might be better to leave vectors for a later chapter.
Comment from #3 so it doesn't get lost:
As a general rule I would suggest to return e.g. a vector of iterates, rather than printing them out inside a function.
When you call the function and return that vector, Julia will automatically output it, including the length of the resulting vector. This then allows you to save the results for later plotting etc.
This is a message that is very important to drill home at the earliest opportunity.