Discussion:
ASCIIMath (was: Alte Programmiersprachen in neuen Compilern)
Add Reply
Stefan Ram
2025-03-24 10:03:55 UTC
Antworten
Permalink
ASCIIMathML soll wohl tatsächlich sogar mathematische
"ad-hoc"-Notation verstehen und
x=(-b +- sqrt(b^2 – 4ac))/(2a)
richtig (so wie vermutlich gemeint) interpretieren!
Da es in "de.alt.folklore.computer" nicht zum Thema paßt:

Newsgroups: de.alt.folklore.computer,de.sci.mathematik
Followup-To: de.sci.mathematik

. ASCIIMathML findet jeweils das längste nächste Symbol. So würde

token_list =[ "sqrt", "+-" ]
input = "+-sqrt(4ac)"

die Symbole

+-
sqrt
(
4
a
c
)

ergeben. Hier ein entsprechendes Python-Skript:

class TokenFinder:
def __init__(self, token_dict):
# Sort the dictionary keys (tokens) by length in descending order
self.sorted_tokens = sorted(token_dict.keys(), key=len, reverse=True)
self.token_dict = token_dict

def next_token(self, s):
# Check for the longest string in the sorted list that is a prefix of s
for token in self.sorted_tokens:
if s.startswith(token):
return token

# If no string in the list is a prefix, return the first character of s (if any)
return s[0] if s else None

def tokens_of(self, s):
while s:
token = self.next_token(s)
# Yield the replacement value if the token is in the dictionary, otherwise yield the token itself
yield self.token_dict.get(token, token)
s = s[len(token):] # Remove the found token from the beginning of s

# Example usage:
token_dict = {"sqrt": "√", "+-": "±"}
finder = TokenFinder(token_dict)

s = "sqrt(x) +- y"
for token in finder.tokens_of(s):
print(token, end='')
print()

# Ausgabe: √(x) ± y

.
Blacky Cat
2025-03-25 05:33:06 UTC
Antworten
Permalink
Hallo,
ja das stimmt.
Ich habe in einen äöteren MathJaX JavaScript Text interpretieren lassen,
der von LaTeX her bekannt ist - also AsciiMath wie \frac{1}{2}.

Ich habe dazu einen Eingabe-Editor gebastelt und bei drücken der Senden-
Taste wird daraus "bildlich/graphisch" aufgehübscht.

Ich habe dazu eine kleine Programmiersprache gebastelt, die alle Anweis-
ungen in $$ $$ als "zu interpretieren" erkennt und Kommentare können per
// one liner comment
wie auf C++ Manier eingefügt werden.

Dann kann man zum Beispiel: $$ \\frac{100}{51} $$
als Anweisung schreiben, und dann auf Send-klicken um eine Grafik zu be-
kommen, die dem AsciiMath entspricht.

Blacky
--
Diese E-Mail wurde von Avast-Antivirussoftware auf Viren geprüft.
www.avast.com
Blacky Cat
2025-03-25 05:34:22 UTC
Antworten
Permalink
Am 25.03.2025 um 06:33 schrieb Blacky Cat:
[...] aber den Link vergessen ... naja Blackies Art halt ...

https://kallup.net/mathe/

Viel Spaß
Blacky
--
Diese E-Mail wurde von Avast-Antivirussoftware auf Viren geprüft.
www.avast.com
Loading...