Changing "," to "."

Hello, I am a teacher from Germany and here we use “,” instead of “.”
So we make decimals like this “4,5” and not “4.5”
I’m looking for a solution on how to change the “,” to “.” via code so Desmos can understand it, but my students can still use the “,” for their numbers.
I already tryd substituteLatexVariable like this:
cell1 = substituteLatexVariable(this.cellContent(1,1),“,”,“.”)
but that didn’t work, it seems like substituteLatexVariable only works for letters as input

I would be greatfull for help. Thanks.

Hello Anno! Right now, there is no direct way to do this, but thank you for putting this on our radar as something that we can add to Desmos to help out those with different notations in other countries!
The other CL specialists and I came up with a couple of ideas for you to try out. One way uses pattern matching and the other uses parseOrderedPair. Take a look at both of those and let us know if you have any questions/feedback!

1 Like

Thanks for the quick help.
It’s a start and it definitely helps. Now I just have to try and figure out how to use this with functions. If I just tried to copy your ideas I would have the problem that it’s only made for a single number and things it doesn’t care about won’t pass through.
I’ll try to split the input, assemble the numbers, pass them through the code, and reassable everything again. I know about programming, but have never worked with this language. If you have a better idea or a solution to my problem, I of coursewouldn’t complain about further help.

I tried to solve the problem in Python first. So if you want to know my idea, you can look at it here:

I’ll try to implement this into my program on my own, but I’m still open for help.
If I manage to do it on my own, I’ll of course upload my solution so that anyone who has the same problem can simply copy past it.

1 Like

I don’t know if the two languages ​​are too different or if I’m just too inexperienced with this language, but I can’t get it to work, and I would really appreciate some help.

Here’s my extension of @ClayRehmel’s solution. You’ll have to add in whatever maximum number of decimals you’d expect.

Note that it still does not work, however, when a decimal is nested anywhere within parts of an expression (e.g. parentheses, radicals, rationals). You can still parse fractions, at least, when it includes a decimal, but your logic would certainly get unwieldy trying to catch all scenarios, and would be much more convenient to have something built in.

Thanks for your Input.
Looking at your code, it’s definitely an upgrade. I noticed that I have a limited length of a function, but I’ve already figured out how to extend it. Unfortunately, since I’m not familiar with this language at all, I don’t fully understand how it works, and so I have no idea why it doesn’t work with parentheses, radicals and rationals, and I have no idea how to fix the problem . It’s not a problem that radicals and rationals don’t work, but the parentheses are important. I’ll try to get my head around it, but would still appreciate any further help or ideas.

If found out that this: part1 = func.parse(mockFunc).nth(1) splits each part after a “,” but why.
what makes it do that and can that somehow be expendend onto more caracters, like for example “(” or “)” for parenthese?
I keep trying to understand whats going on.

Function call is looking for a function with some number of arguments. A comma within parentheses doesn’t split to make a new argument because parentheses need to close (e.g. “(3” wouldn’t make sense as a function argument). It could have points as arguments for example.

You could potentially try to further parse the functions arguments, but again that would probably be a rabbit hole of conditionally parsing if it matches a fraction or radical pattern, or using the same strategy of parsing with function call, but not adding in parentheses to catch when commas occur within parentheses.

If you look at screen 2, I started to try and parse the first argument if it’s a fraction or has parentheses, but gets too involved very quickly…

Is it possible that something could be implemented for this?
Maybe just the substituteLatexVariable that i tried to use first but it works not just for numbers but for any string? I think something like this could be useful in many cases.