Mathmark

Mathmark is a proposed standard notation for ASCII mathematics. Markdown has proven to be a workable standard for marking up "normal" text. I propose that Mathmark might have similar utility in marking up mathematical text…

The basic rules of Mathmark are these:

Arithmetic and comparison operators are as in C or Nickle. The division symbol "/" is an exception: it is of lower precedence than addition or subtraction, making many kinds of markup more natural. (This is the same precedence as "horizontal bar" division in standard mathematics.) Equality is also an exception, being represented by "="; there is no assignment statement. Comparisons are not Boolean-valued expressions; instead, chains of comparisons represent pairwise comparisons between adjacent expressions as in standard mathematical practice. As in Nickle, exponentiation is indicated by the double star "**", and is left associative and of higher precedence than multiplication.

Identifiers may be multi-character, and follow the identifier rules of C or Nickle. There is no implicit multiplication: space-separated identifiers are presumably function arguments. Function definition and invocation is either as in Haskell or as in C. In the former style function application has lower precedence than operators, functions are fully curried, and arguments are simply placed after the function in definitions and invocations. In the latter style function application binds more tightly than other operators, functions are uncurried, and arguments are a parenthesized, comma-separated list of expressions. The two styles may be mixed. Thus:
r3 x y z = x**2 + y**2 + z**2
4 * r3(x, y, z) = r3(2 * x, 2 * y, 2 * z)

Named operators are available, and are inferred from context. Commonly-used named operators include "div", "max", and "min". New named operators may be defined as in the Z notation; their precedence and associativity should be described in accompanying text if unclear. For example

x absdist y = | x - y | = | y - x |

Tuples and sequences are considered isomorphic, and are represented as comma-separated lists with angle brackets. Ellipsis is allowed in sequences. Sequence selection is with the "@" operator, which is left-associative and has precedence just below the structure operator ".". The structure operator "." has C precedence and associativity: structured values are denoted by "value.component" notation. As in dynamic languages, the components of a structured value are regarded as an infinite set: any component may be defined or referenced at any time. Operations on simple values can be extended to operations on structured values; unless the extension is "obvious", the definition of such an operation should be given explicitly.
p - p' = p'' where p''.x = p.x - p'.x, p''.y = p.y - p'.y
p dist p' = sqrt((p.x - p'.x)**2 - (p.y - p'.y)**2) = sqrt((p - p')**2)
</pre></blockquote>


</blockquote>