Skip to main content

Algorithm lines in CalcMe

A brand new way to define variables and create algorithms is available in CalcMe The purpose of this page is to provide an outline of what this new feature has to offer, the problems it intends to solve and the expected user interaction.

calc.algorithm_line_example.calc.png

Problems intended to be solved

After deeply analyzing the CalcMe user experience, we realized several minor issues could be improved with the algorithm lines development. The main problems this new feature intends to address are:

  • It's not possible to copy and paste multiple lines in CalcMe. From now on, it will be possible to easily reuse parts of an algorithm.

  • It's complicated to remember by heart all the commands. The new autocompletion option will help you find the appropriate function at each moment.

  • CalcMe presents performance issues in sessions with an intermediate-length due to the many instances of MathType editors that need to be used. You won't face this problem anymore by generating the algorithms with the provided plain text.

  • It's not possible to add comments inside multiple line structures. Besides, it's also impossible to switch a line from being commented to being active quickly.

Expected user interaction

A new button in the toolbar allows you to instance a code editor. That button enables the algorithm line feature in the current line, and you can enter your algorithms directly there.

toolbar_button.png

User-created functions and constants (such as the represented by r(), create_random_matrix(m,n) and A) get their styling once the code editor loses focus to avoid the performance impact of updating the grammar every keystroke.

On the other hand, variables defined inside a code editor are available in posterior standard CalcMe lines for operations or value checking. Besides, multiple code editors can be created on a page, and each one can access the variables of the previous ones.

calc.interaction_example.calc.png

Caution

If you're using the feature in a WirisQuizzes version before 4.2.7 (which includes WirisQuizzes 3), sessions with only algorithms won't be detected. This can be solved by adding something in CalcMeSheet, as you can see in the screenshot below.

wq3_workaround.png

Algorithms already written in CalcMe sheet

If you had an algorithm already written in the CalcMe sheet, you could automatically convert it to the code editor. There is a new button in the toolbar allowing you to do so.

sheet_to_algorithm.gif

Thus, you will be able to translate those old algorithms that gave you performance problems to the code line box.

About the syntax

The syntax used in the code editors is the Omega language, the internal language of the Wiris CAS kernel. Even though it's very similar to the syntax used in standard CalcMe lines, several actions help you get the correct syntax.

  • Clicking a button from CalcMe menu while inside a code editor will enter its Omega equivalent expression:

syntax_menu.png
  • Using the function name autocompletion mode through the shortcut Ctrl + Space (Cmd + Shift + Space in macOS):

syntax_autocompletion.png

Comment syntax

As mentioned above, it's possible to use the comment syntax within the code editor. You can use the symbol # to mark a line as a comment and the sequence /# to start a comment block (you can close it using the symbol #/).

syntax_comment.png

String substitution command

If you want to use the string_substitution() command within a mathematical expression, you will have to keep using the CalcMe sheet accordingly. It's a limitation of the current editor and, although it's not ideal, the formulas won't be displayed properly if they are included through the code editor.

calc.string_substitution_example.calc.png