From 31ae5bbbbc30dfe56792e6b588e837f9cdb183cd Mon Sep 17 00:00:00 2001 From: minjaesong Date: Sun, 27 Dec 2020 02:24:05 +0900 Subject: [PATCH] basicdoc: word position self-reference joke is now automated --- assets/disk0/tbas/doc/langguide.tex | 7 +++++-- assets/disk0/tbas/doc/tbasman.tex | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/assets/disk0/tbas/doc/langguide.tex b/assets/disk0/tbas/doc/langguide.tex index 8fbbab1..e993784 100644 --- a/assets/disk0/tbas/doc/langguide.tex +++ b/assets/disk0/tbas/doc/langguide.tex @@ -99,7 +99,7 @@ Consider the following code: Here, we have defined two functions to use in the program: \code{POW2} and \code{DCOS}. Also observe that functions are defined using variable \code{N}s, but we use them with \code{X} in line 40 and with \code{A} in line 80: yes, functions can have their local name so you don't have to carefully choose which variable name to use in your subroutine. -Except a function can't have statements that spans 2- or more BASIC lines; but there are ways to get around that, including \code{DO} statement and \emph{functional currying}. +Except a function can't have statements that spans two- or more BASIC lines; but there are ways to get around that, including \code{DO} statement and \emph{functional currying}\newcounter{curryingappearance}\setcounter{curryingappearance}{\value{page}} This sample program also shows \code{FOREACH} statement, which is same as \code{FOR} but works with arrays. @@ -153,7 +153,10 @@ Here, \code{K} will contain the values of $1!$, $2!$ \ldots\ $10!$. Right now we \section[Currying]{Haskell Curry Wants to Know Your Location} \label{currying101} -Two pages ago there was a mentioning about something called \emph{functional currying}. So what the fsck is currying? Consider the following code: +\newcounter{curryingselfref} +\setcounter{curryingselfref}{\value{page} - \value{curryingappearance}} + +\cnttoenglish{\thecurryingselfref}{page} ago there was a mentioning about something called \emph{functional currying}. So what the fsck is currying? Consider the following code: \begin{lstlisting} 10 DEFUN F(K,T)=ABS(T)==K diff --git a/assets/disk0/tbas/doc/tbasman.tex b/assets/disk0/tbas/doc/tbasman.tex index 2b54e30..4267481 100644 --- a/assets/disk0/tbas/doc/tbasman.tex +++ b/assets/disk0/tbas/doc/tbasman.tex @@ -31,6 +31,8 @@ \usepackage[most]{tcolorbox} \usepackage{listings} \usepackage{amsmath,amssymb} +\usepackage{calc} +\usepackage{ifthen} \usepackage{lineno} % debug @@ -131,6 +133,22 @@ tabsize=3 } +\newcommand{\cnttoenglish}[2]{{% +\ifthenelse{#1=1}{One}{% +\ifthenelse{#1=2}{Two}{% +\ifthenelse{#1=3}{Three}{% +\ifthenelse{#1=4}{Four}{% +\ifthenelse{#1=5}{Five}{% +\ifthenelse{#1=6}{Six}{% +\ifthenelse{#1=7}{Seven}{% +\ifthenelse{#1=8}{Eight}{% +\ifthenelse{#1=9}{Nine}{% +\ifthenelse{#1=10}{Ten}{% +\ifthenelse{#1=11}{Eleven}{% +\ifthenelse{#1=12}{Twelve}{% +\arabic{#1}% +}}}}}}}}}}}}} \ifthenelse{#1=1}{#2}{#2s}} + \addtocontents{toc}{\protect\thispagestyle{empty}} % no page number for the TOC header page \aliaspagestyle{part}{empty} % aliasing PART as empty so that page number would not be printed \aliaspagestyle{chapter}{section} % aliasing CHAPTER as section so that page numbering style would be the same as section