4
$\begingroup$

Update

In version 13.2 StringRepeat[" ", 0] produces an empty string.


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$
10
  • 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, 2015 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, 2015 at 20:44
  • $\begingroup$ I'll go ahead and report this as a suggestion for you. $\endgroup$
    – Searke
    Oct 21, 2015 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, 2015 at 21:42
  • $\begingroup$ This would affect other functions like StringPadRight, StringPadLeft and would be impossible with StringPartition $\endgroup$
    – Searke
    Oct 21, 2015 at 21:48

1 Answer 1

4
$\begingroup$

In version 13.2 StringRepeat[" ", 0] produces an empty string.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.