Re: [racket-users] LaTeX

2019-08-27 Thread Norman Gray


Hendrik, hello.

(a tangent...)

On 27 Aug 2019, at 14:16, Hendrik Boom wrote:

> That said, it doesn't even have a stable syntax.  I tried to find a
> grammar for parsing LaTeX, and discovered there is none.  It seems
> LaTeX's macros do the parsing, and they're a Turing-complete 
> laanguage.

Oh yes.  LaTeX is fun.

TeX has a _small_ set of very primitive commands -- loosely like 
add-character-to-list or add-box-to-list-of-boxes, none of which a 
normal user would type or be aware of -- and all of the rest is macro 
expansion.  LaTeX is just a package of macros, originally written by 
Leslie Lamport, sitting on top of (the package of macros that is) plain 
TeX.

The tokeniser turns "\emph  {x$y$}" into

  

at which point "emph" is looked up to see if it's a macro. "emph" is, 
and requires an argument, so the tokeniser then gobbles

  

this is replaced by the expansion of "emph"+arguments, which is then 
expanded, and so on until something expands to one or more primitives.  
Thus what syntax there is is entirely specified by the definitions of 
the macros.

Even the tokeniser is reconfigurable on the fly, so that the following 
is a valid LaTeX file:

 \documentclass{article}

 \catcode`@=0
 @catcode`<=1
 @catcode`>=2
 @catcode`;=14
 @catcode`\%=11 ; % is now just an ordinary alphabetic-letter

 @begin
 Hello, this is a 100% valid @LaTeX@ file.
 @end Although mathematical expressions
> (which Latex is all about) have tree structure (like MathML does, and
> is excessively wordy), for the most part latex represents mathematics
> as just a symbol cluster.

TeX doesn't represent any of the structure of the mathematics, because 
it's focused purely on the typesetting of maths (and other text).  
Semantics, as far as TeX is concerned, is for human readers.  Thus in 
$\sum_i x_i$, the fact that \sum is a summation is not important; what's 
important is that it's in a category of objects for which certain 
spacing and layout rules apply, and these are 
managed/implemented/realised by the internals of TeX -- the primitives 
-- not by any macros.

Best wishes,

Norman


-- 
Norman Gray  :  https://nxg.me.uk
SUPA School of Physics and Astronomy, University of Glasgow, UK

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/C703278D-3C0C-4305-8904-4DBC2379D105%40glasgow.ac.uk.


Re: [racket-users] LaTeX inspired key bindings

2016-01-28 Thread Vincent St-Amour
On Thu, 28 Jan 2016 16:30:57 -0600,
Brian Adkins wrote:
> 
> I'm sure this is a really bad idea, but I couldn't resist after finding 
> section 3.3.8 in the Dr. Racket documentation - what fun :)
> 
> (define (∃ member list)
>   (cond [ (∅? list) ∅ ]
> [ (≡ member (α list)) list ]
> [ else (∃ member (ω list)) ]))
> 
> (∃ 8 '(3 9 8 5))
> 
> Using "alpha" for "car" kind of makes sense, but using "omega" for
> "cdr" really doesn't - I expect it should return the last element of
> the list, but I couldn't think of any greek symbol that might mean
> "tail".

Δ ?

(also works with a:car :: d:cdr :) )

Vincent

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.