| 1 |
% \iffalse meta-comment |
| 2 |
% !TEX program = pdfLaTeX |
| 3 |
%<*internal> |
| 4 |
\iffalse |
| 5 |
%</internal> |
| 6 |
%<*readme> |
| 7 |
----------------------------------------------------------------- |
| 8 |
##### lambdax --- lambda expression |
| 9 |
- Source repository: https://github.com/rogard/lambdax |
| 10 |
- Released under the LaTeX Project Public License v1.3c or later |
| 11 |
- See http://www.latex-project.org/lppl.txt |
| 12 |
----------------------------------------------------------------- |
| 13 |
%</readme> |
| 14 |
%<*internal> |
| 15 |
\fi |
| 16 |
\def\nameofplainTeX{plain} |
| 17 |
\ifx\fmtname\nameofplainTeX\else |
| 18 |
\expandafter\begingroup |
| 19 |
\fi |
| 20 |
%</internal> |
| 21 |
%<*install> |
| 22 |
\input l3docstrip.tex |
| 23 |
\keepsilent |
| 24 |
\askforoverwritefalse |
| 25 |
\preamble |
| 26 |
---------------------------------------------------------------- |
| 27 |
lambdax --- lambda expression |
| 28 |
Released under the LaTeX Project Public License v1.3c or later |
| 29 |
See http://www.latex-project.org/lppl.txt |
| 30 |
---------------------------------------------------------------- |
| 31 |
|
| 32 |
\endpreamble |
| 33 |
\postamble |
| 34 |
|
| 35 |
Copyright (C) 2021 by Erwann Rogard |
| 36 |
|
| 37 |
This work may be distributed and/or modified under the |
| 38 |
conditions of the LaTeX Project Public License (LPPL), either |
| 39 |
version 1.3c of this license or (at your option) any later |
| 40 |
version. The latest version of this license is in the file: |
| 41 |
|
| 42 |
http://www.latex-project.org/lppl.txt |
| 43 |
|
| 44 |
This work is "maintained" (as per LPPL maintenance status) by |
| 45 |
Erwann Rogard. |
| 46 |
|
| 47 |
This work consists of the file lambdax.dtx and the derived files: |
| 48 |
lambdax.sty, and lambdax.pdf. |
| 49 |
|
| 50 |
\endpostamble |
| 51 |
\generate{ |
| 52 |
\file{\jobname.sty}{\from{\jobname.dtx}{package}} |
| 53 |
} |
| 54 |
%</install> |
| 55 |
%<install> \endbatchfile |
| 56 |
%<*internal> |
| 57 |
\generate{ |
| 58 |
\file{\jobname.ins}{\from{\jobname.dtx}{install}} |
| 59 |
} |
| 60 |
\nopreamble\nopostamble |
| 61 |
\generate{ |
| 62 |
\file{README.md}{\from{\jobname.dtx}{readme}} |
| 63 |
} |
| 64 |
\ifx\fmtname\nameofplainTeX |
| 65 |
\expandafter\endbatchfile |
| 66 |
\else |
| 67 |
\expandafter\endgroup |
| 68 |
\fi |
| 69 |
%</internal> |
| 70 |
%<package> \NeedsTeXFormat{LaTeX2e}[2021-06-01] |
| 71 |
%<package> \RequirePackage{expl3, xparse, xtemplate, l3keys2e}[2021-06-01] |
| 72 |
%<package> \RequirePackage{keyparse}[2021-08-18] |
| 73 |
%<package> \ProvidesExplPackage |
| 74 |
%<package> {lambdax} % Package name |
| 75 |
%<package> {2021-08-18} % Release date |
| 76 |
%<package> {1.1} % Release version |
| 77 |
%<package> {lambdax --- Lambda expression } % Description |
| 78 |
%<*driver> |
| 79 |
\documentclass[show-notes]{l3doc}%^^A full |
| 80 |
% ^^A \listfiles |
| 81 |
\usepackage[french, german, english]{babel} |
| 82 |
\usepackage{bookmark, enumitem, tcolorbox, xparse} |
| 83 |
\usepackage[bibencoding=auto, backend=biber, sorting=ynt]{biblatex} |
| 84 |
\usepackage[T1]{fontenc} |
| 85 |
\ExplSyntaxOn |
| 86 |
% ^^A *** Sectioning |
| 87 |
\tl_gset:Nn \partname {Part}%^^A allows to test w/o babel |
| 88 |
% ^^A |
| 89 |
\ExplSyntaxOff |
| 90 |
% ^^A *** Typesetting |
| 91 |
\ProvideDocumentCommand{\docdescrf}{}{\sffamily\bfseries\tiny{}} |
| 92 |
% ^^A *** bibliography |
| 93 |
\begin{filecontents*}{\jobname.bib} |
| 94 |
@misc{erw-ccool, |
| 95 |
author = {Rogard, Erwann}, |
| 96 |
title = {The \pkg{ccool} package for \LaTeX}, |
| 97 |
note = {\url{https://github.com/rogard/ccool/blob/master/ccool.pdf}}, |
| 98 |
year = {2020}} |
| 99 |
@misc{erw-keyparse, |
| 100 |
author = {Rogard, Erwann}, |
| 101 |
title = {The \pkg{keyparse} package for \LaTeX}, |
| 102 |
note = {\url{https://github.com/rogard/keyparse/blob/master/keyparse.pdf}}, |
| 103 |
year = {2021}} |
| 104 |
@manual{xparse, |
| 105 |
title = {The \pkg{xparse} package}, |
| 106 |
author = {The \LaTeX3 Project Team}, |
| 107 |
year = {2019}, |
| 108 |
note = {\url{https://ctan.math.illinois.edu/macros/latex/contrib/l3packages/xparse.pdf}}, |
| 109 |
annote = {} } |
| 110 |
@misc{a-188053, |
| 111 |
author = {@{}sean-allred}, |
| 112 |
title = {``How to create lambda expressions?''}, |
| 113 |
year = {2014}, |
| 114 |
note = {\url{https://tex.stackexchange.com/a/188053/112708}}} |
| 115 |
@misc{q-610349, |
| 116 |
author = {@{}Erwann}, |
| 117 |
title = {``Troubleshooting \PrintIndex \PrintChanges''}, |
| 118 |
year = {2021}, |
| 119 |
note = {\url{https://tex.stackexchange.com/questions/610349/troubleshooting-printindex-printchanges}}} |
| 120 |
\end{filecontents*} |
| 121 |
\addbibresource{\jobname.bib} |
| 122 |
% ^^A *** Lists |
| 123 |
\newlist{arab-inl}{enumerate*}{1} |
| 124 |
\setlist[arab-inl]{label=\arabic*)} |
| 125 |
\newlist{colon-inl}{itemize*}{1} |
| 126 |
\setlist[colon-inl] |
| 127 |
{ %^^Abefore=\noindent, |
| 128 |
label={}, |
| 129 |
itemjoin={{; }}, |
| 130 |
after={{.}}} |
| 131 |
\newlist{descr}{description}{1} |
| 132 |
\setlist[descr]{nosep, align=left, itemindent=0pt, |
| 133 |
font=\sffamily\tiny} |
| 134 |
% ^^A *** This package's loading |
| 135 |
\usepackage{lambdax} |
| 136 |
\usepackage{hyperref} %^^A comes last |
| 137 |
\begin{document} |
| 138 |
\DocInput{\jobname.dtx} |
| 139 |
\end{document} |
| 140 |
%</driver> |
| 141 |
% \fi |
| 142 |
% |
| 143 |
% \GetFileInfo{\jobname.sty} |
| 144 |
% \title{The \pkg{lambdax} package\thanks{^^A |
| 145 |
% This file describes version \fileversion, last revised \filedate.^^A |
| 146 |
% }^^A |
| 147 |
% } |
| 148 |
% \author{Erwann Rogard\thanks{first.lastname at gmail.com}} |
| 149 |
% |
| 150 |
% \date{Released \filedate} |
| 151 |
% \begin{documentation} |
| 152 |
% \maketitle |
| 153 |
% \begin{abstract} |
| 154 |
% This is a \LaTeX package that provides `lambda expressions', in other words |
| 155 |
% an interface by which one consecutively, first, |
| 156 |
% specifies the parameters and replacement code of a document-command\cite{xparse}, |
| 157 |
% and, second, evaluates it with compatible arguments. |
| 158 |
% Optionally, one can recurse. |
| 159 |
% For example, |
| 160 |
% |\LambdaX[mm]<t^>{$#1$#2}{x}| |
| 161 |
% |{,~}^{y}{~and~}^{z}{.}|, |
| 162 |
% where |<.>| specifies the recurse paramater, |
| 163 |
% expands to ``\LambdaX[mm]<t^>{$#1$#2}{x}{,~}^{y}{~and~}^{z}{.}'' |
| 164 |
% \end{abstract} |
| 165 |
% \part{Usage}\label{part:usage} |
| 166 |
% |
| 167 |
% \tableofcontents |
| 168 |
% |
| 169 |
% \section{Settings} |
| 170 |
% |
| 171 |
% The options hereafter are load-time-only. |
| 172 |
% |
| 173 |
% \DescribeOption{xparse-command} |
| 174 |
% \begin{descr} |
| 175 |
% \item[Side effect] Sets the xparse-document-command used by \cs{lambdax:nn} |
| 176 |
% \item[Initial] \cs[no-index]{DeclareDocumentCommand} |
| 177 |
% \end{descr} |
| 178 |
% |
| 179 |
% \section{Programming} |
| 180 |
% \begin{function} |
| 181 |
% {\lambdax:nn} |
| 182 |
% \begin{syntax} |
| 183 |
% \cs{lambdax:nn}\Arg{argspec}\Arg{code}\meta{args} |
| 184 |
% \end{syntax} |
| 185 |
% \end{function} |
| 186 |
% \begin{descr} |
| 187 |
% \item[Expands to] \meta{code}, \meta{args} replacing the parameters implied by \meta{argspec} |
| 188 |
% \end{descr} |
| 189 |
% |
| 190 |
% \begin{function} |
| 191 |
% {\lambdax:nnn} |
| 192 |
% \begin{syntax} |
| 193 |
% \cs{lambdax:nn}\Arg{argspec}\Arg{code}\Arg{bool-arg-type}\meta{args}\meta{bool-arg} |
| 194 |
% \end{syntax} |
| 195 |
% \end{function} |
| 196 |
% \begin{descr} |
| 197 |
% \item[Limitation] That of \pkg{keyparse}\cite{erw-keyparse}'s \texttt{argspec} collection. |
| 198 |
% \item[Argspec] Examples of \meta{bool-arg-type}\cite{xparse} and \meta{bool-arg} are |s| and |*|, respectively. |
| 199 |
% \item[Semantics] That of \cs{lambdax:nn} and recurse if applicable. |
| 200 |
% \end{descr} |
| 201 |
% |
| 202 |
% \begin{function}[EXP] |
| 203 |
% {\lambdax_xcmd_if:NTF} |
| 204 |
% \begin{syntax} |
| 205 |
% \cs{lambdax_xcmd_if:NTF:Nn}\meta{xparse-command}\Arg{code~if~true}\Arg{code~if~false} |
| 206 |
% \end{syntax} |
| 207 |
% \end{function} |
| 208 |
% |
| 209 |
% \section{Document} |
| 210 |
% \begin{function} |
| 211 |
% {\LambdaX} |
| 212 |
% \begin{syntax} |
| 213 |
% \cs[no-index]{LambdaX}\oarg{argspec}|<|\meta{bool-arg-type}|>|\Arg{code} |
| 214 |
% \end{syntax} |
| 215 |
% \begin{descr} |
| 216 |
% \item[Adapts] \cs{lambda:nn} and \cs{lambda:nnn} |
| 217 |
% \end{descr} |
| 218 |
% \end{function} |
| 219 |
% |
| 220 |
% \part{Other} |
| 221 |
% \section{Acknowledgment} |
| 222 |
% The basis for \cs{lambdax:nn} originates with \cite{a-188053}. Except for chaining, it was already provided by \cite{erw-ccool}. |
| 223 |
% |
| 224 |
% \section{Bibliograhy} |
| 225 |
% \printbibliography[heading=none] |
| 226 |
% |
| 227 |
% \changes{Version 1.0} |
| 228 |
% {2020/08/03} |
| 229 |
% {Initial version} |
| 230 |
% \changes{Version 1.1} |
| 231 |
% {2020/08/18} |
| 232 |
% {Dependency lex.sty renamed keyparse.sty} |
| 233 |
% \clearpage |
| 234 |
% \StopEventually{ |
| 235 |
% \PrintChanges |
| 236 |
%^^A \PrintIndex % waiting for a response to \cite{q-610349} |
| 237 |
% } |
| 238 |
% |
| 239 |
% \end{documentation} |
| 240 |
% \begin{implementation} |
| 241 |
% |
| 242 |
% \part{Implementation}\label{part:impl} |
| 243 |
% |
| 244 |
% \begin{macrocode} |
| 245 |
%<*package> |
| 246 |
%<@@=lambdax> |
| 247 |
\ExplSyntaxOn |
| 248 |
% \end{macrocode} |
| 249 |
% \section{Auxiliary} |
| 250 |
% \begin{macrocode} |
| 251 |
\cs_generate_variant:Nn\tl_count:n{e} |
| 252 |
\cs_generate_variant:Nn\int_eval:n{e} |
| 253 |
\cs_generate_variant:Nn\bool_if:nT{o, e} |
| 254 |
% \end{macrocode} |
| 255 |
% \begin{macro}{\@@_str_case_empty:n} |
| 256 |
% \begin{macrocode} |
| 257 |
\cs_new:Nn |
| 258 |
\@@_str_case_empty:n |
| 259 |
{{#1} |
| 260 |
{\c_empty_tl}} |
| 261 |
% \end{macrocode} |
| 262 |
% \end{macro} |
| 263 |
% \section{\textsf{xcmdif}} |
| 264 |
% \begin{macro}[int]{not-xparse} |
| 265 |
% \begin{macrocode} |
| 266 |
\msg_new:nnn{@@} |
| 267 |
{not-xparse} |
| 268 |
{Expecting~an~xparse~command,~got~#2} |
| 269 |
% \end{macrocode} |
| 270 |
% \end{macro} |
| 271 |
% \begin{variable} |
| 272 |
% {\c@@_xcmdname_tl} |
| 273 |
% \begin{macrocode} |
| 274 |
\tl_const:Nn |
| 275 |
\c@@_xcmdname_tl |
| 276 |
{ {NewDocumentCommand} |
| 277 |
{RenewDocumentCommand} |
| 278 |
{ProvideDocumentCommand} |
| 279 |
{DeclareDocumentCommand} |
| 280 |
{NewExpandableDocumentCommand} |
| 281 |
{RenewExpandableDocumentCommand} |
| 282 |
{ProvideExpandableDocumentCommand} |
| 283 |
{DeclareExpandableDocumentCommand} } |
| 284 |
% \end{macrocode} |
| 285 |
% \end{variable} |
| 286 |
% \begin{macro} |
| 287 |
% {\@@_xcmd_if:nTF, |
| 288 |
% \@@_xcmd_if:eTF, |
| 289 |
% \lambdax_xcmd_if:NTF, |
| 290 |
% \@@_xcmd_else_error:Nn} |
| 291 |
% \begin{macrocode} |
| 292 |
\prg_new_conditional:Nnn |
| 293 |
\@@_xcmd_if:n{TF} |
| 294 |
{\exp_args:Nnx |
| 295 |
\str_case:nnTF{#1} |
| 296 |
{ \tl_map_function:NN |
| 297 |
\c@@_xcmdname_tl |
| 298 |
\@@_str_case_empty:n} |
| 299 |
{\prg_return_true:} |
| 300 |
{\prg_return_false:}} |
| 301 |
\cs_generate_variant:Nn\@@_xcmd_if:nTF{e} |
| 302 |
\cs_new:Nn |
| 303 |
\lambdax_xcmd_if:NTF |
| 304 |
{\@@_xcmd_if:eTF |
| 305 |
{\cs_to_str:N#1}{#2}{#3}} |
| 306 |
\cs_new:Nn |
| 307 |
\@@_xcmd_else_error:Nn |
| 308 |
{ \lambdax_xcmd_if:NTF#1 |
| 309 |
{ #2 } |
| 310 |
{ \msg_error:nne{@@} |
| 311 |
{not-xparse} |
| 312 |
{\token_to_str:N#1} } } |
| 313 |
% \end{macrocode} |
| 314 |
% \end{macro} |
| 315 |
% \begin{variable} |
| 316 |
% {\c@@_xenv_tl} |
| 317 |
% \begin{macrocode} |
| 318 |
\tl_const:Nn |
| 319 |
\c@@_xenv_tl |
| 320 |
{ {NewDocumentEnvironment} |
| 321 |
{RenewDocumentEnvironment} |
| 322 |
{ProvideDocumentEnvironment} |
| 323 |
{DeclareDocumentEnvironment} } |
| 324 |
% \end{macrocode} |
| 325 |
% \end{variable} |
| 326 |
% \begin{macro}[int] |
| 327 |
% {\@@_msg_name:n} |
| 328 |
% \begin{macrocode} |
| 329 |
\cs_new:Nn |
| 330 |
\@@_msg_name:n{msg_\g@@_opt_msg_tl{}:#1} |
| 331 |
% \end{macrocode} |
| 332 |
% \end{macro} |
| 333 |
% \section{\textsf{lambda}}\label{impl:lambda} |
| 334 |
% \begin{macro} |
| 335 |
% {\@@_placeholder:n, |
| 336 |
% \@@_placeholder:e, |
| 337 |
% \@@_argspec:n, |
| 338 |
% \@@_argspec_count:n, |
| 339 |
% \@@_chain_position:n, |
| 340 |
% \@@_chain_placeholder:n} |
| 341 |
% \begin{macrocode} |
| 342 |
\cs_new:Nn\@@_placeholder:n{#### #1} |
| 343 |
\cs_generate_variant:Nn\@@_placeholder:n{o,e} |
| 344 |
\cs_new:Nn\@@_argspec:n{\keyparse_eval:nn{argspec}{#1}} |
| 345 |
\cs_new:Nn\@@_argspec_count:n{\tl_count:e{\@@_argspec:n{#1}}} |
| 346 |
\cs_new:Nn\@@_chain_position:n{\int_eval:e{\@@_argspec_count:n{#1}+1}} |
| 347 |
\cs_new:Nn\@@_chain_placeholder:n |
| 348 |
{\@@_placeholder:e |
| 349 |
{\@@_chain_position:n{#1}}} |
| 350 |
% \end{macrocode} |
| 351 |
% \end{macro} |
| 352 |
% \begin{macro} |
| 353 |
% {\@@_lambda:Nnn, |
| 354 |
% \@@_lambda_dev:N, |
| 355 |
% \@@_lambda_doc:NN } |
| 356 |
% \begin{macrocode} |
| 357 |
\cs_new_protected:Nn \@@_lambda:Nnn |
| 358 |
{\exp_args:NNx |
| 359 |
#1 \@@_lambda |
| 360 |
{#2} |
| 361 |
{#3} |
| 362 |
\@@_lambda} |
| 363 |
\cs_generate_variant:Nn\@@_lambda:N{c} |
| 364 |
\cs_new_protected:Nn |
| 365 |
\@@_lambda_chain:Nnnn |
| 366 |
{ \tl_set:Nn |
| 367 |
\l@@_head_tl |
| 368 |
{\exp_args:NNx#1 \@@_lambda_chain |
| 369 |
{#2#3} } |
| 370 |
\exp_args:Nx |
| 371 |
\l@@_head_tl |
| 372 |
{\exp_not:n{#4} \exp_not:N |
| 373 |
\bool_if:oT |
| 374 |
{\@@_chain_placeholder:n{#2}} |
| 375 |
{\exp_not:N\@@_lambda_chain}} |
| 376 |
\@@_lambda_chain} |
| 377 |
\cs_set_protected:Nn |
| 378 |
\@@_lambda_dev:N |
| 379 |
{ \cs_new_protected:Nn |
| 380 |
\lambdax:nn |
| 381 |
{ \@@_lambda:Nnn #1 |
| 382 |
{##1}{##2} } |
| 383 |
\cs_new_protected:Nn |
| 384 |
\lambdax:nnn |
| 385 |
{ \@@_lambda_chain:Nnnn #1 |
| 386 |
{##1}{##2}{##3} } } |
| 387 |
\cs_set_protected:Nn |
| 388 |
\@@_lambda_doc:N |
| 389 |
{ \NewDocumentCommand |
| 390 |
#1 { O{m} d<> m } |
| 391 |
{\IfValueTF{##2} |
| 392 |
{ \lambdax:nnn { ##1 } { ##2 } { ##3 } } |
| 393 |
{ \lambdax:nn { ##1 } { ##3 } } } } |
| 394 |
\cs_generate_variant:Nn\@@_lambda_doc:N{c} |
| 395 |
% \end{macrocode} |
| 396 |
% \end{macro} |
| 397 |
% \section{Settings} |
| 398 |
% \begin{macrocode} |
| 399 |
\keys_define:nn{ @@ } |
| 400 |
{ dev.code:n = { |
| 401 |
\@@_xcmd_else_error:Nn#1 |
| 402 |
{\@@_lambda_dev:N#1 } |
| 403 |
}, |
| 404 |
internal / document-command-name.code:n = { \@@_lambda_doc:c{#1} }, |
| 405 |
internal / document-command-name.initial:n = { LambdaX }, |
| 406 |
xparse-command.code:n = |
| 407 |
{ \@@_xcmd_else_error:Nn #1 |
| 408 |
{ \keys_set:nn{ @@ }{ dev = #1 } } }, |
| 409 |
xparse-command .initial:n = { \DeclareDocumentCommand } |
| 410 |
} |
| 411 |
% \end{macrocode} |
| 412 |
% \begin{macrocode} |
| 413 |
\ProcessKeysOptions{@@} |
| 414 |
\ExplSyntaxOff |
| 415 |
%</package> |
| 416 |
% \end{macrocode} |
| 417 |
% \end{implementation} |
| 418 |
% \Finale |
| 419 |
\endinput |