daniel3735928559/guppy

Print multiplication as asterix (*) in text content output

Closed this issue · 4 comments

Hi Daniel

is there anyway to show multiplications as asterix in the text version of the function?

Currently entering xy output 'xy' rather than 'x*y' which is the way most language interpret multiplications.

Ah, I guess otherwise you could still get someone writing cos and meaning cos. I've fixed it, although it is slightly fragile (in the sense that someone adding custom symbols might cause it to break slightly if they add a binary operation and do not place it in the "operations" group).

Would it work to just enforce spaces between every letter in a e node and just have the parser figure it out? (That is, if a user writes cos meaning c*o*s, then it will be rendered in text format as c o s.) This way, it is unambiguous, but doesn't require special code for checking what happens at boundaries.

Sure, leaving spaces between should be fine. Although if someone writes cosine ('cos') wouldn't that automatically entails a function input as in cos() which ought to be interpreted differently from the combination of variables c,o, and s?
If a custom variable c or co is used in an editor, the user would be forced to identify which symbol they wish to insert (c/co or cos).
In the case of a variable cos being used, I would suggest that the plugin implements a set of reserved names, basically all function and greek letters shortcodes should automatically be reserved.
In my usage of multiple editors I actually track all teh variables inserted into an editor instance and ensure they are all unique. This way there is no ambiguity as to what the user is expecting in the formula.
Maybe the plugin can return false|true on the add_symbol function if the custom symbol is duplicate|unique respectively and reject the symbol if it is not unique?

works beautifully, thanks!

If someone enters c, then, o, then [space], then s, it will give cos without autocompleting to the cos() function. Not likely to happen legitimately, but something to be wary of (for example, when the symbols cos and sin are blacklisted).

I am not too worried issues with add_symbol being misused at the moment.

I think I'll leave it as-is for now and keep an eye on it as usage evolves.