Strange behaviour of the dollar sign ($) in CAS with the Substitute command

Alexander Perl shared this problem 1 year ago
Not a Problem

Hello there!


I recently discovered GeoGebra CAS's functionality of referencing previous cells' outputs via the dollar sign ($). My observation is as follows (please correct me if I'm wrong):

  • "$n" references the output of the n-th CAS cell.
  • "$" references the output of the previous CAS cell and automatically evaluates to "$n" with n being the number of the previous cell.

So, effectively, "$" is equivalent to "ans" on typical pocket calculators like "Texas Instruments TI-30X II" or "%" in Wolfram Mathematica. Great feature, I love it!


However, I have stumbled upon a strange situation involving the "Subsitute" command, where the automatic evaluation of "$" to "$n" does not work and directly addressing "$n" is the only way to do it (see attachment).

a06c8553a3f389ee2dfa684f6b10b8a4

This really does not seem like intended behaviour to me, so please take a look at it and fix it, so it works as expected!


Thank you and kind regards

Files: cas.png

Comments (3)

photo
1

Thank you for checking on it so fast!

It's true, taking "#" instead of "$" is a possible option, but it copies the whole output into the input cell and leaves no trace of the used command "#".

For didactic reasons, I would really prefer keeping the new input cell short and in a way that makes it clear, what exactly was entered. In my eyes, the automatic replacement of "$" with "$n" on evaluation is also not the most beautiful way, but definitely more acceptable than the automatic replacement of "#" with the whole previous output!

photo
1

Sorry, I think you'll just need to use the $n syntax

photo
1

And why is that?

The documentation clearly states that "$" inserts a reference to the previous output. There is no remark like "...except when used as a second argument in the Subsitute command, even if it would be very useful especially there".

Perhaps it would be easier to understand if you elaborated on WHY it doesn't work.

© 2020 International GeoGebra Institute