Created
June 17, 2012 05:49
-
-
Save zr-tex8r/2943564 to your computer and use it in GitHub Desktop.
A version of python.sty that runs not Python but Gauche
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% This is a modified version of python.sty by Martin R. Ehmsen. | |
%% Licensed under GPL v2 or later. | |
%% You can obtain the original version at: | |
%% http://mirror.ctan.org/macros/latex/contrib/python.zip | |
\NeedsTeXFormat{LaTeX2e}[1994/12/01] | |
\ProvidesPackage{goshutex}[2012/06/17 v0.1 Gauche in LaTeX] | |
\newwrite\@out | |
\newwrite\@module | |
\begingroup \catcode `|=0 \catcode `[=1 | |
\catcode`]=2 \catcode `\{=12 \catcode `\}=12 | |
\catcode`\\=12 |gdef|@xgauche#1\end{gauche}[|immediate|write|@out[#1]|end[gauche]] | |
|endgroup | |
\def\gauche{\kernel@ifnextchar [{\@gauche}{\@gauche[]}} | |
\def\@gauche[#1]{% | |
\gdef\@gaucheinclude{#1} | |
\immediate\openout\@out=\jobname.scm | |
\newlinechar='15 | |
\begingroup \catcode`\^^M=12 % | |
\let\do\@makeother\dospecials\obeyspaces% | |
\@xgauche} | |
\def\endgauche{% | |
\endgroup | |
\immediate\closeout\@out | |
%\@writemodule | |
\immediate\write18{cat \@gaucheinclude\space\jobname.scm | gosh > \jobname.scm.out 2> \jobname.scm.err} | |
\immediate\input\jobname.scm.out} | |
%\def\@writemodule{% | |
%\immediate\openout\@module=latex.scm | |
%\immediate\write\@module{(define jobname "\jobname")} | |
%\immediate\closeout\@module} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use srfi-1) | |
(use srfi-13) | |
(define (nabeazz n) | |
(for-each display | |
(append-map nabeazz-step (iota n 1)))) | |
(define (nabeazz-step n) | |
(if (int-is-aho? n) | |
`("{\\AhoFont " ,n "} ") | |
`(,n " "))) | |
(define (int-is-aho? n) | |
(or (= (modulo n 3) 0) | |
(string-index (number->string n) #\3))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{article} | |
\usepackage{goshutex} | |
\usepackage{type1cm} | |
\newcommand*{\AhoFont}{\usefont{OT1}{cmfr}{m}{it}\LARGE} | |
\begin{document} | |
% Library code in nabeazz.scm, and the environemtn | |
% contains the main code to run. | |
\begin{gauche}[nabeazz.scm] | |
(nabeazz 40) | |
\end{gauche} | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment