News for hackers. Stuff that matters.
Re:Handcalcs: Automatically render Latex equations from Pyth... by abnry on Tuesday September 01, 2020 @05:28PM (#24347302)
This is fantastic! The best use case I can think of is to verify your python formulas are correct. It is much easier to read math notation than code.
Re:Handcalcs: Automatically render Latex equations from Pyth... by enriquto on Wednesday September 02, 2020 @05:01AM (#24351329)
> It is much easier to read math notation than code.

I agree.

And for writing, the difference is even bigger than for reading. Thus, what we need is the reverse tool, that translates our beautiful formulas into the damned code!

Re:Handcalcs: Automatically render Latex equations from Pyth... by ajuc on Wednesday September 02, 2020 @07:30AM (#24352187)
The problem isn't translation, it's input. Keyboard is designed for serial 1-dimensional input, formulas are nested trees. The approaches I've seen are:

- OCR a handwritten formula (unreliable but the most convenient)

- make the user write serialized code and show it as formula (basically this submission, but also latex etc. - misses the point)

- force the user to design the formula tree with some graphical editor and fill it with values and identifiers later (office suites do this and it's such a pain to constantly switch between keyboard and mouse)

Re:Handcalcs: Automatically render Latex equations from Pyth... by abdullahkhalids on Wednesday September 02, 2020 @08:43AM (#24352635)
When you write formulas by hand, don't you write them in serial format i.e. symbol by symbol? The advantage of hand is that you can often write the symbols in whatever order you want, while latex has pretty much a canonical order.

Eg. by hand, you can write down the denominator of a fraction before the numerator. While latex require numerator before denominator.

Re:Handcalcs: Automatically render Latex equations from Pyth... by ajuc on Wednesday September 02, 2020 @08:56AM (#24352719)
You filled the numerator and want to switch to denominator - how do you specify that with keyboard? You could use TAB or something, but that denominator could be nested in 10 levels of other stuff so you probably use mouse or jump for 5 seconds randomly until you get to the right place.

The problem is that you have to jump which "by hand" is natural (start writing slightly lower) while with keyboard requires switching to mouse and back or remembering shortcuts and modeling the tree structure of your formula in your head to know where the shortcut will jump.

Same with introducing new levels of nesting.

That's why I prefer just writing code for formulas over graphical editors.

Re:Handcalcs: Automatically render Latex equations from Pyth... by abdullahkhalids on Wednesday September 02, 2020 @03:22PM (#24356885)
I am comparing latex with hand. Both are serial, except hand has more freedom. There is no mouse required to use latex. You can write arbitrary math expressions without the mouse.
Re:Handcalcs: Automatically render Latex equations from Pyth... by enriquto on Wednesday September 02, 2020 @09:24AM (#24352946)
this is exactly the purpose of vim, dude
Re:Handcalcs: Automatically render Latex equations from Pyth... by ajuc on Wednesday September 02, 2020 @09:56AM (#24353242)
I haven't seen tree-edit mode in vim, I've seen it in emacs for clojure (it was called paredit or sth like that) and I've tried to learn it but couldn't get used to it in a few days. Maybe it would work better for formulas.
Re:Handcalcs: Automatically render Latex equations from Pyth... by enriquto on Wednesday September 02, 2020 @11:48AM (#24354359)
There are a lot of "fancy" packages tailored to latex and formulas like vim-latexsuite, that set up place holders that you can navigate around and whatnot.

But even without all that, a very basic thing that you can do is move around the matching pairs of braces (and brackets, and other paired things) using %

If you do not want to move, but only see where the matching brace is, you can "set showmatch" and it will flash the matching brace when your cursor passes through the other one. This is really helpful for writing nested formulas (although a better strategy is to add a lot of newlines and whitespace so that the structure of your formulas is clear).

Re:Handcalcs: Automatically render Latex equations from Pyth... by ajuc on Wednesday September 02, 2020 @11:52AM (#24354407)
Even mcedit shows matching braces, that's not tree editing :) That would be editor showing a formula in graphic form and allowing you to jump around on it and add/move around nested parts of it with shortcuts.
Re:Handcalcs: Automatically render Latex equations from Pyth... by enriquto on Wednesday September 02, 2020 @12:31PM (#24354858)
The show matching braces thing is not essential. But, barring the visual formula, %-navigation through braces is tree navigation.
Re:Handcalcs: Automatically render Latex equations from Pyth... by ajuc on Wednesday September 02, 2020 @02:03PM (#24355925)
But if you have serialized code tree navigation isn't needed, the whole point was to make it graphical.