summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/lisp-on-tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-03-05 00:33:46 +0000
committerKarl Berry <karl@freefriends.org>2013-03-05 00:33:46 +0000
commitd472c7d8c47d5a08e34a9f4713164afc5e7a1406 (patch)
tree4249b1eff690be906945d15b1e39e33037b1abdc /Master/texmf-dist/doc/latex/lisp-on-tex
parent0d0778a39975e8293bde2267504f53bd9d3610a6 (diff)
lisp-on-tex (4mar13)
git-svn-id: svn://tug.org/texlive/trunk@29291 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/lisp-on-tex')
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/LICENSE28
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/README229
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/examples/fact.pdfbin0 -> 36635 bytes
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/examples/fact.tex30
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/examples/fpnummodule-mandelbrot.pdfbin0 -> 32298 bytes
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/examples/fpnummodule-mandelbrot.tex55
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/examples/rocket.pdfbin0 -> 30978 bytes
-rw-r--r--Master/texmf-dist/doc/latex/lisp-on-tex/examples/rocket.tex26
8 files changed, 368 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/LICENSE b/Master/texmf-dist/doc/latex/lisp-on-tex/LICENSE
new file mode 100644
index 00000000000..71f8691a7aa
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/lisp-on-tex/LICENSE
@@ -0,0 +1,28 @@
+LISP on TeX
+
+lisp-on-tex.sty, lisp-arith.sty,
+lisp-latexutil.sty, lisp-prim.sty,
+lisp-read.sty, lisp-string.sty,
+lisp-util.sty, lisp-mod-fpnum.sty,
+fact.tex, rocket.tex, fpnummodule-mandelbrot.tex
+
+Copyright (c) 2012 2013, HAKUTA Shizuya
+ All rights reserved.
+
+
+Redistribution and use in source and binary forms,
+with or without modification, are permitted provided
+that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+--
+ Copyright 1993 1994 1995 1996 1997 1998 1999
+ The LaTeX3 Project and any individual authors listed elsewhere
+ in this file.
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/README b/Master/texmf-dist/doc/latex/lisp-on-tex/README
new file mode 100644
index 00000000000..336bb425c31
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/lisp-on-tex/README
@@ -0,0 +1,229 @@
+
+%%
+%% This is file `README'.
+%%
+%% License: Modified BSD - see LICENSE file.
+%%
+
+===== LISP on TeX --- A LISP interpreter on TeX ======
+Version 1.0
+Author : HAKUTA Shizuya <hak7a3@live.jp>
+
+==== Introduction ====
+LISP on TeX is a LISP interpreter written only with TeX macros.
+It works as a style file of LaTeX.
+LISP on TeX adopts static scoping, dynamic typing, and eager evaluation.
+We can program easily with LISP on TeX.
+
+==== Files ====
+
+README : This file.
+--------------------------------------------------------------------------------------
+LICENCE : About LICENCE.
+--------------------------------------------------------------------------------------
+lisp-on-tex.sty : Main routine. (evaluator)
+--------------------------------------------------------------------------------------
+lisp-prim.sty : Primitive functions. (Automatically loaded by lisp.sty)
+--------------------------------------------------------------------------------------
+lisp-read.sty : Parser. (Automatically loaded by lisp.sty)
+--------------------------------------------------------------------------------------
+lisp-arith.sty : Arithmetical functions. (Automatically loaded by lisp.sty)
+--------------------------------------------------------------------------------------
+lisp-string.sty : Functions which manipulates strings.
+ : (Automatically loaded by lisp.sty)
+--------------------------------------------------------------------------------------
+lisp-latexutil.sty : Utility functions for LaTeX.
+ : (Automatically loaded by lisp.sty)
+--------------------------------------------------------------------------------------
+lisp-util.sty : Utility functions written with LISP on TeX.
+ : (Automatically loaded by lisp.sty)
+--------------------------------------------------------------------------------------
+lisp-mod-fpnum.sty : The module which enables us to use fixed point numbers.
+ : See the "Fixed Point Numbers" section in this document.
+--------------------------------------------------------------------------------------
+examples/* : Example files. See the "Examples" section.
+--------------------------------------------------------------------------------------
+==== Usage ====
+To use LISP on TeX, write
+
+ \usepackage{lisp}
+
+in the preamble of document.
+
+We can load module files
+using \usepackage. For example, the command
+
+ \usepackage{lisp-mod-fpnum}
+
+loads the module of fixed point numbers.
+
+It the document, we can start LISP interpreter with \lispinterp.
+For example,
+
+ \lispinterp{(\texprint :1)}
+
+outputs "1".
+
+To get more detail, please read example files.
+It is the better way to know about LISP on TeX.
+
+==== Examples ====
+ * fact.tex
+ -- Calculate the factorial function.
+ * rocket.tex
+ -- Show how to use "mutable" locations.
+ * fpnum-mandelbrot.tex
+ -- Calculate the mandelbrot set.
+ -- It takes a long long time to typeset.
+
+==== Syntax ====
+The syntax of LISP on TeX is the following;
+
+<S-exp> ::= <cons>
+ | <int>
+ | <string>
+ | <symbol>
+ | <bool>
+ | <nil>
+ | <p-module>
+ | <skip>
+ | <dimen>
+<cons> ::= (<S-exp>+) | (<S-exp> . <S-exp>)
+<int> ::= :[TeX's integer]
+<string> ::= '[TeX's tokens]'
+<symbol> ::= [a control sequence]
+<bool> ::= /t | /f
+<nil> ::= ()
+<p-module>::= +{<modname>::<tokens>}
+<modname> ::= [TeX's tokens]
+<tokens> ::= [TeX's tokens]
+<skip> ::= @[TeX's skip]
+<dimen> ::= ![TeX's dimen]
+
+==== Functions and Others ====
+=== Special Forms ===
+ * (\define \symbol <S-exp>)
+ -- Binds the evaluation result of <S-exp> to \symbol.
+ * (\lambda <ptn> <S-exp>)
+ -- Lambda abstraction. The bind pattern <ptn> has the following syntax;
+ <ptn> ::= <symbol> | (<symbol>*) | (<symbol>+ . <symbol>)
+ * (\quote <S-exp>)
+ -- Return <S-exp>.
+ * (\lispif <S-exp 1> <S-exp 2> <S-exp 3>)
+ -- Branch. The type of the evaluation result of <S-exp 1> must be bool.
+ * (\defmacro \symbol <Lambda abstraction>)
+ -- Define a macro.
+ * (\begin <S-exp>+)
+ -- Evaluate all arguments in a sequential order
+ and returns the the evaluation result of the last argument.
+ * (\defineM \symbol <S-exp>)
+ -- Binds the evaluation result of <S-exp> to \symbol
+ and the location which binds \symbol becomes "mutable".
+ * (\setB \symbol <S-exp>)
+ -- If location of which binds \symbol is "mutable",
+ the evaluation result of <S-exp> is stored in the location.
+
+=== Evaluation ===
+ * (\eval <S-exp>)
+ -- Evaluate <S-exp> in the current environment.
+ * (\apply <func> <list>)
+ -- Evaluate (<func> <args>) where <list> = (<args>).
+
+=== Types ===
+ * (\intQ <S-exp>)
+ -- If the evaluation result of <S-exp> is an integer, it returns /t.
+ Otherwise, it returns /f.
+ -- Likewise, \pairQ, \booleanQ, \symbolQ, \stringQ, \dimenQ, \skipQ,
+ \nilQ, \funcQ, \closureQ, and \macroQ are defined.
+ * (\listQ <S-exp>)
+ -- Return /t iff <S-exp> is a nil or a cons cell.
+ Otherwise, it returns /f.
+ * (\procedureQ <S-exp>)
+ -- Return /t iff <S-exp> is a closure or a function (or a macro).
+ * (\intTOstring <integer>)
+ -- convert the argument into a string.
+
+=== Arithmetical Functions ===
+ * (\+ <S-exp>*)
+ -- Addition.
+ -- If, the argument is empty, it returns 0.
+ * (\- <S-exp>+)
+ -- Subtraction.
+ * (\* <S-exp>*)
+ -- Multiplication.
+ -- If, the argument is empty, it returns 1.
+ * (\/ <S-exp>+)
+ -- Division.
+ * (\mod <int 1> <int 2>)
+ -- Modulus.
+ * (\< <S-exp 1> <S-exp 2>)
+ -- Let n be the evaluation result of <S-exp 1> and m be that of <S-exp 2>.
+ If n < m, it returns /t. Otherwise, it returns /f.
+
+=== Manipulation of Strings ===
+ * (\concat <string 1> <string 2>)
+ -- Concatenate two strings.
+ * (\group <string>)
+ -- Grouping.
+ -- If <string> is 'foo\bar{baz}', it returns '{foo\bar{baz}}'.
+ * (\ungroup <string>)
+ -- Ungrouping.
+ -- If <string> is '{foo\bar{baz}}', it returns 'foo\bar{baz}'.
+
+=== Manipulation of Cons Cells ===
+ * (\cons <S-exp 1> <S-exp 2>)
+ -- Create a cons cell: the CAR of the cell is the evaluation result of
+ <S-exp 1> and the CDR of the cell is the evaluation result of
+ <S-exp 2>.
+ * (\car <cons>)
+ -- Get CAR part of the argument.
+ * (\cdr <cons>)
+ -- Get CAR part of the argument.
+ * (\length <list>)
+ -- If the argument is "list", count the length of the argument.
+ -- We define the term "list" as following;
+ - The value nil.
+ - A cons cell whose CDR is "list".
+ * (\nth <list> <int>)
+ -- Get the <int>-th element of the <list>.
+ -- The numbering starts from 0.
+
+=== Logical Functions ===
+ * (\and <bool 1> <bopl 2> ...)
+ * (\or <bool 1> <bopl 2> ...)
+ * (\not <bool>)
+
+=== Misc ===
+ * (\= <S-exp 1> <S-exp 2>)
+ -- If the evaluation result of <S-exp 1> equals that of <S-exp 2>,
+ it returns /t. Otherwise, it returns /f.
+ * (\print <S-exp>)
+ -- Write the evaluation result of <S-exp> as LISP on TeX form.
+ * (\texprint <S-exp>)
+ -- Write the evaluation result of <S-exp> as useful form in TeX.
+ * (\immediatewrite)
+ -- Flush the output buffer immediately.
+ -- It may brake the evaluation routine.
+ * (\message <str>)
+ -- Write <str> to console.
+ * (\map <proc> <list 1> <list 2> ...)
+ -- Mapping function like Scheme's map.
+ * (\let <bindings> <body>)
+ -- Let bindings.
+ * (\letM <bindings> <body>)
+ -- Let bindings (mutable).
+
+==== Fixed Point Numbers ====
+ * +{fpnum::<fixed point number>}
+ -- Create an fixed point number.
+ * (\fpplus <S-exp>*)
+ -- Addition.
+ -- If, the argument is empty, it returns 0.0.
+ * (\fpmunus <S-exp>+)
+ -- Subtraction.
+ * (\fpmul <S-exp>*)
+ -- Multiplication.
+ -- If, the argument is empty, it returns 1.0.
+ * (\fplt <S-exp 1> <S-exp 2>)
+ -- Let n be the evaluation result of <S-exp 1> and m be that of <S-exp 2>.
+ If n < m, it returns /t. Otherwise, it returns /f.
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/examples/fact.pdf b/Master/texmf-dist/doc/latex/lisp-on-tex/examples/fact.pdf
new file mode 100644
index 00000000000..bef54e029ca
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/lisp-on-tex/examples/fact.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/examples/fact.tex b/Master/texmf-dist/doc/latex/lisp-on-tex/examples/fact.tex
new file mode 100644
index 00000000000..39fb7eeb116
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/lisp-on-tex/examples/fact.tex
@@ -0,0 +1,30 @@
+\documentclass{article}
+\usepackage{lisp-on-tex}
+\lispinterp{%
+ (\define \sq (\lambda (\n) (\* \n \n)))
+ (\define \fact (\lambda (\n) (\lispif (\= \n :0) :1 (\* \n (\fact (\- \n :1))))))
+ }
+\newcommand\sq[1]{\lispinterp{(\texprint (\sq :#1))}}
+\newcommand\fact[1]{\lispinterp{(\texprint (\fact :#1))}}
+
+\begin{document}
+\section{Factorials and Squares}
+ \begin{center}
+ \begin{tabular}{r||rr}\hline\hline
+ $n$ & $n!$ & $n^2$ \\
+ \hline
+ 1 & \fact{1} & \sq{1} \\
+ 2 & \fact{2} & \sq{2} \\
+ 3 & \fact{3} & \sq{3} \\
+ 4 & \fact{4} & \sq{4} \\
+ 5 & \fact{5} & \sq{5} \\
+ 6 & \fact{6} & \sq{6} \\
+ 7 & \fact{7} & \sq{7} \\
+ 8 & \fact{8} & \sq{8} \\
+ 9 & \fact{9} & \sq{9} \\
+ 10 & \fact{10} & \sq{10} \\
+ 11 & \fact{11} & \sq{11} \\
+ \hline
+ \end{tabular}
+ \end{center}
+\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/examples/fpnummodule-mandelbrot.pdf b/Master/texmf-dist/doc/latex/lisp-on-tex/examples/fpnummodule-mandelbrot.pdf
new file mode 100644
index 00000000000..fc227eccc5d
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/lisp-on-tex/examples/fpnummodule-mandelbrot.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/examples/fpnummodule-mandelbrot.tex b/Master/texmf-dist/doc/latex/lisp-on-tex/examples/fpnummodule-mandelbrot.tex
new file mode 100644
index 00000000000..f0cf68798b5
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/lisp-on-tex/examples/fpnummodule-mandelbrot.tex
@@ -0,0 +1,55 @@
+\documentclass{article}
+\usepackage[pdftex,a3paper,margin=1pt,landscape]{geometry}
+\newcount\mlength
+\newcount\cstate
+\newdimen\mandelunit
+\mandelunit=0.5pt
+
+\def\w{%
+ \ifnum\cstate=1 \global\advance\mlength1
+ \else \vrule width \mlength\mandelunit height \mandelunit depth 0pt \global\mlength1 \fi
+ \global\cstate1}
+\def\b{%
+ \ifnum\cstate=-1 \global\advance\mlength1
+ \else \hspace*{\mlength\mandelunit}\global\mlength1 \fi
+ \global\cstate-1}
+\def\r{%
+ \ifnum\cstate=1\hspace*{\mlength\mandelunit}\else\vrule width \mlength\mandelunit height \mandelunit depth 0pt \fi
+ \global\cstate0 \global\mlength0}
+
+\usepackage{lisp-on-tex}
+\usepackage{lisp-mod-fpnum}
+\lispinterp{%
+ (\define \maxloop :20)
+ (\define \scale +{fpnum::0.002})
+ (\define \isMandell
+ (\lambda (\a \b \k \x \y)
+ (\lispif (\< \maxloop \k) /t
+ (\lispif (\fplt +{fpnum::4.0} (\fpplus (\fpmul \x \x) (\fpmul \y \y)))
+ /f
+ (\isMandell \a \b (\+ \k :1)
+ (\fpplus \a (\fpmul \x \x) (\fpminus (\fpmul \y \y)))
+ (\fpplus \b (\fpmul +{fpnum::2.0} \x \y)))))))
+ (\define \drawMandell (\lambda (\a \b)
+ (\begin
+ (\lispif (\isMandell \a \b :0 +{fpnum::0} +{fpnum::0})
+ (\texprint '\b') (\texprint '\w'))
+ (\immediatewrite))))
+ (\define \loopMandell (\lambda (\a \b)
+ (\lispif (\fplt \b +{fpnum::-1.0}) ()
+ (\begin
+ (\drawMandell \a \b)
+ (\lispif (\fplt +{fpnum::0.5} \a)
+ (\begin
+ (\texprint '\r\\')
+ (\immediatewrite)
+ (\loopMandell +{fpnum::-1.5} (\fpminus \b \scale)))
+ (\loopMandell (\fpplus \a \scale) \b))))))
+}
+
+\begin{document}
+ \thispagestyle{empty}
+ \noindent
+ \leavevmode\baselineskip=\mandelunit
+ \lispinterp{(\loopMandell +{fpnum::-1.5} +{fpnum::1.0})}
+\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/examples/rocket.pdf b/Master/texmf-dist/doc/latex/lisp-on-tex/examples/rocket.pdf
new file mode 100644
index 00000000000..482cb62993b
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/lisp-on-tex/examples/rocket.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/lisp-on-tex/examples/rocket.tex b/Master/texmf-dist/doc/latex/lisp-on-tex/examples/rocket.tex
new file mode 100644
index 00000000000..c4ed29648fd
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/lisp-on-tex/examples/rocket.tex
@@ -0,0 +1,26 @@
+\documentclass{article}
+\usepackage{lisp-on-tex}
+\lispinterp{%
+%rocket body
+(\define \rocket
+ (\letM ((\count :11))
+ (\lambda ()
+ (\begin
+ (\setB \count (\- \count :1))
+ (\lispif (\< \count :0)
+ (\texprint '{\small fired...}\\')
+ (\lispif (\= \count :0)
+ (\texprint '{\Large FIRE!}\\')
+ (\texprint (\concat 'count ' (\intTOstring \count) '...\\'))))))))
+(\define \MAX :15)
+%LOOP function
+(\define \loop
+ (\lambda (\n)
+ (\lispif (\= \n \MAX)
+ ()
+ (\begin (\rocket) (\loop (\+ \n :1))))))
+}
+\begin{document}
+\noindent\lispinterp{(\loop :0)}
+Test done.
+\end{document} \ No newline at end of file