summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/expl3/l3candidates.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-03-31 00:04:47 +0000
committerKarl Berry <karl@freefriends.org>2010-03-31 00:04:47 +0000
commit3ab55a61f6f8d2218a8f3175bc7481ce162b60d3 (patch)
treef606e0c2117a8058213441400e50ba25400ba94a /Master/texmf-dist/source/latex/expl3/l3candidates.dtx
parent035ea73193af75f6ade46e306603e61d82b24950 (diff)
expl3 1881 (30mar10)
git-svn-id: svn://tug.org/texlive/trunk@17631 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/expl3/l3candidates.dtx')
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3candidates.dtx101
1 files changed, 69 insertions, 32 deletions
diff --git a/Master/texmf-dist/source/latex/expl3/l3candidates.dtx b/Master/texmf-dist/source/latex/expl3/l3candidates.dtx
index 63385cbcd41..b753191559d 100644
--- a/Master/texmf-dist/source/latex/expl3/l3candidates.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3candidates.dtx
@@ -1,5 +1,5 @@
% \iffalse
-%% File: l3extra.dtx Copyright (C) 2005-2009 LaTeX3 project
+%% File: l3candidates.dtx Copyright (C) 2005-2009 LaTeX3 project
%%
%% It may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -47,13 +47,13 @@
%\iffalse
\documentclass[full]{l3doc}
\begin{document}
-\DocInput{l3extra.dtx}
+\DocInput{l3candidates.dtx}
\end{document}
%</driver>
% \fi
%
%
-% \title{The \textsf{l3extra} package\thanks{This file
+% \title{The \textsf{l3candidates} package\thanks{This file
% has version number \fileversion, last
% revised \filedate.}}
% \author{\Team}
@@ -78,17 +78,6 @@
% \section{Functions for functions}
%
%
-% \begin{function}{\exp_arg:x}
-% \begin{syntax}
-% "\exp_arg:x" \Arg{text}
-% \end{syntax}
-% Fully expands <text> before passing it to the input stream.
-% Not expandable.
-% \begin{texnote}
-% In pdf\TeX\ 1.5 and Lua\TeX, this can be done expandably with "\expanded".
-% \end{texnote}
-% \end{function}
-%
%
% \section{Functions for token lists}
%
@@ -192,6 +181,28 @@
% \end{function}
%
%
+% \begin{function}{\clist_if_in_numrange:nn / (TF)}
+% \begin{syntax}
+% "\clist_if_in_numrange:nnTF" \Arg{intexpr} \Arg{numrange}
+% \Arg{true} \Arg{false}
+% \end{syntax}
+% When parsing user input to specify whether numerical elements
+% should be displayed/operated upon, it is common to use input such as
+% `|-4,7-11,17-|' to indicate ranged but sometimes discontiguous sets.
+% (In this particular example, we'd be specifying
+% $x\le4 \wedge 7\le x\le 11 \wedge x\ge 17$.)
+% This function can be used to test whether the input number
+% (actually <intexpr>) exists within the specified <numrange>.
+%
+% <numrange> need not be sorted and may contain overlapping ranges.
+% Numbers inside ranges may consist of integer expressions or anything
+% considered by \TeX\ to be a number
+% (such as `|`\A|', which is decimal number 65).
+%
+% This function could probably be made expandable with sufficient effort.
+% \end{function}
+%
+%
%
% \end{documentation}
%
@@ -209,19 +220,6 @@
%<*initex|package>
% \end{macrocode}
%
-% \begin{macro}{\exp_arg:x}
-% \begin{macrocode}
-\cs_new:Npn \exp_arg:x #1
- {
- \group_begin:
- \cs_set:Npx \cs_tmp: {#1}
- \exp_args:wN
- \group_end:
- \cs_tmp:
- }
-% \end{macrocode}
-% \end{macro}
-%
%
% \begin{macro}{\tl_trim_spaces:n,\tl_trim_spaces:N}
% \begin{macrocode}
@@ -279,9 +277,9 @@
}
\cs_new:Npn \char_transform:NN
{
- \msg_error:nn {l3extra} {naked-char-transform}
+ \msg_error:nn {l3prg} {naked-char-transform}
}
-\msg_new:nnn {l3extra} {naked-char-transform}
+\msg_new:nnn {l3prg} {naked-char-transform}
{
This command can only appear within the first\\
argument of \string\tl_transform:nn.
@@ -313,9 +311,9 @@
\seq_set_eq:NN \l_tmpa_seq #1
\seq_set_eq:NN \l_tmpb_seq #2
\prg_stepwise_inline:nnnn{1}{1}{\l_tmpa_int}{
- \seq_pop:NN \l_tmpa_seq \l_tmpa_tl
- \seq_pop:NN \l_tmpb_seq \l_tmpb_tl
- \exp_args:NVV #3 \l_tmpa_tl \l_tmpb_tl
+ \seq_pop:NN \l_tmpa_seq \l_kernel_tmpa_tl
+ \seq_pop:NN \l_tmpb_seq \l_kernel_tmpb_tl
+ \exp_args:NVV #3 \l_kernel_tmpa_tl \l_kernel_tmpb_tl
}
}{\ERROR}
}
@@ -364,6 +362,45 @@
% \end{macrocode}
% \end{macro}
%
+%
+%
+% \begin{macro}[TF]{\clist_if_in_numrange:nn}
+% A `numrange' is like |-2,5-8,17-| (can be unsorted).
+% \begin{macrocode}
+\prg_new_conditional:Nnn \clist_if_in_numrange:nn {TF,T,F} {
+ \bool_set_false:N \l_clist_numrange_bool
+ \clist_map_inline:nn {#2} {
+ \_clist_numrange_parse:nw {#1} ##1 - \q_marker - \q_nil
+ }
+ \bool_if:NTF \l_clist_numrange_bool \prg_return_true: \prg_return_false:
+}
+\cs_set:Npn \_clist_numrange_success: {
+ \bool_set_true:N \l_clist_numrange_bool
+ \clist_map_break:
+}
+\cs_set:Npn \_clist_numrange_parse:nw #1 #2 - #3 - #4 \q_nil {
+ \tl_if_empty:nTF {#4}{
+ \intexpr_compare:nT {#1=#2} {\_clist_numrange_success:}
+ }{
+ \tl_if_empty:nTF {#3}{
+ \intexpr_compare:nT {#1>=#2} {\_clist_numrange_success:}
+ }{
+ \tl_if_empty:nTF {#2}{
+ \intexpr_compare:nT {#1<=#3} {\_clist_numrange_success:}
+ }{
+ \intexpr_compare:nT {#1>=#2} {
+ \intexpr_compare:nT {#1<=#3}
+ {\_clist_numrange_success:}
+ }
+ }
+ }
+ }
+}
+\bool_new:N \l_clist_numrange_bool
+% \end{macrocode}
+% \end{macro}
+%
+%
% \begin{macrocode}
%</initex|package>
% \end{macrocode}