sazroberson

60 Reputation

4 Badges

10 years, 162 days

MaplePrimes Activity


These are replies submitted by sazroberson

A note with regards to using Vector() : if you use [] subscripting, such as

  R[k] := r;

then you can only store into existing elements, but if you use () subscripting, such as

 R(k) := r;

then it will extend the Vector if need be.

 

If the array might extend but you know a maximum length, then you can initialize the array to the proper length. For example,

L := [0 $ 10];

would create L as a list of 10 zeros.

@Carl Love showstat() shows the result of de-parsing the parsed maple code, and so uses whatever indentation showstat() cares to implement; we don't know what the source looked like. In particular, it could be the case that the content that shows up for isprime() [u]is[/u] the result of a procedure such as you suggest. Or the original might have written out 2*3*5*7*11*13*17*19*23*31*37*41*43*47*53*59*61*67*71*73*79*83*89*97 where the 2305567963945518424753102147331756070 appears.

When I showstat() isprime(), the numbers that show up do not use the \ continuation facility. I have not tried it from command line though.

@Carl Love I cannot use FormatMessage itself as my goal is validating that the right number of parameters have been provided for error strings. But I can perhaps canniblize the code there.

@Carl Love That looks like it should work.

It is disappointing that iterating along the string is necessary. I have been over using MATLAB for some time; it has the "match" option to its regexp() operator for this.

You could also try temporarily changing your keyboard to (for example) US English, to see whether that made a difference.

@PerKirkegaard in some places in the Maple GUI interface, shift-return, whose key label is "enter" on Mac keyboards, can have a different result than return by itself. It can, for example, mean "put in a line break but do not execute what has been entered". If you are not using shift-return then the more correct label for the key you are using is "return" rather than "enter". Both names have been used for the same key, historically, so in informal discussions it is seldom productive to distinguish between "return" and "enter", and I doubt that your difficulty has anything to do with the possible difference between the two words.

@Preben Alsholm Thank you, I was discovering that representation in the early hours of the morning today, but had not had time to work it through.

@Carl Love I no longer recall the context, but there were some times over the years where I used \ as part of entering very long integer constants. It wouldn't surprise me if I was creating test-cases at the time :)

In the specific case of string constants, you may wish to take advantage of the fact that adjacent string constants, separated by whitespace, are joined together automatically. For example if you code

   "hello" "there"

then the result would be "hellothere". (From which you may note that whitespace is not added between the parts.)

This applies only to literal strings, not to cases where something would execute to produce a string. For example,

 

  "uvwxy" StringTools[Char](122)

will produce "uvwxy" "z" at execution time, rather that "uvwxyz" like "uvwxy" "z" would.

@Hapseeker Also remember that simplify() in general does not try "hard" unless you give it the 'size' option. It does not make a difference in your example, but keep in mind for future that if your goal is "compact output" then use the 'size' option.

@PerKirkegaard On Mac keyboards, "enter" is shift-return .

1 2 Page 2 of 2