The following Mathematica function f creates a string of whitespace of length n.
f[n_]:=Fold[StringJoin,"",Array[" "&,n]]
There must be a zillion alternatives to create this function.
How would you have done it?
f[n_] := StringJoin @ ConstantArray[" ", n]
Edit: since @ is as idiomatic as @@ and a bit faster (thanks to Mr.Wizard for benchmarking) and shorter i updated the solution.
f[n_] := FromCharacterCode[ConstantArray[32, {n}]]
By the way: you should be aware that this type of question is frowned upon in the faq:
What kind of questions should I not ask here?
You should only ask practical, answerable questions based on actual problems that you face. Chatty, open-ended questions diminish the usefulness of our site and push other questions off the front page. To prevent your question from being flagged and possibly removed, avoid asking subjective questions where …
1. every answer is equally valid: “What’s your favorite ______?”
Don't be surprised if the question is closed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With