3
$\begingroup$

I'm wondering about the rationale behind the design decision that leads to the following expression throwing an error:

StringRepeat[" ", 0]

(* StringRepeat::intp: Positive integer expected at position 2 in StringRepeat[ ,0]. >> *)

I would expect it to just return an empty string.

I'd like to understand what reasons could be behind this decision.

$\endgroup$
  • 1
    $\begingroup$ I think "bug" is probably too strong a word, but it seems like an infelicitous choice, given how similar functions (Table, ConstantArray et c.) work. $\endgroup$ – Pillsy Oct 21 '15 at 20:07
  • 1
    $\begingroup$ IMO quite possibly an oversight, why don't you contact support and ask? This is one of the recently added convenience functions (some of which are not yet up to the usual quality standards). $\endgroup$ – Szabolcs Oct 21 '15 at 20:44
  • $\begingroup$ I'll go ahead and report this as a suggestion for you. $\endgroup$ – Searke Oct 21 '15 at 21:41
  • $\begingroup$ I can't think of too many examples in my head, but I'm sure if I think I can come up with some plausible logic for why this should be :). $\endgroup$ – Searke Oct 21 '15 at 21:42
  • $\begingroup$ This would affect other functions like StringPadRight, StringPadLeft and would be impossible with StringPartition $\endgroup$ – Searke Oct 21 '15 at 21:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.