Creating a variable length string of whitespaces in Mathematica
问题 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? 回答1: 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. 回答2: f[n_] := FromCharacterCode[ConstantArray[32, {n}]] By the way: you should be aware that this type of