Debian Codegraph @

texmf-dist/tex/plain/xintsession/xintsession.tex

raw
1 % Release 0.4alpha (2021-11-01) of xintsession.tex
2 % author: Jean-Francois Burnol
3 % License: LPPL 1.3c (author-maintained)
4 % Usage: execute "etex (or pdftex) xintsession"
5 % If available use "rlwrap etex xintsession" for a better experience
6 \edef\xsrestorenewlinechar{\newlinechar\the\newlinechar\relax}\newlinechar10\relax%
7 % we load it with \newlinechar set in order for its error messages
8 % to be nicer (since xintexpr 1.4g)
9 \input xintexpr.sty\relax%
10 \unless\ifdefined\xintreloadxintlog% defined at 1.4e
11 {\catcode32=11%
12 \errhelp{Please update xintexpr to at least 1.4e. Aborting input.^^JSay `x' to exit.}%
13 \errmessage{xintexpr is too old. Say `x' to exit, `h' for help}}\endinput\fi%
14 \input xintbinhex.sty\relax%
15 \input polexpr.sty\relax% this will crash with polexpr versions < 0.8
16 \let\PolToExprOneTerm\PolToExprOneTermStyleB%
17 % \XINTrestorecatcodes. Although we morally assume normal catcodes
18 % we use it as a convenience: strangely named, it is to be used in
19 % an \edef to store there catcodes and \endlinechar (but not
20 % \newlinechar). It was renamed at 1.4e and this is one reason
21 % why we aborted input with earlier xintexpr...
22 \edef\xsrestorecatcodes{\XINTrestorecatcodes\xsrestorenewlinechar}%
23 \endlinechar 13 % default anyhow
24 \newlinechar 10
25 \catcode`_ 11
26 \catcode`& 11
27 \catcode`@ 11
28 \catcode`^ 11
29 \catcode`$ 7 %$
30 \catcode0 12
31 \newwrite\xs_out
32 \edef\xs_name{\jobname-\expandafter\xint_gobble_ii\the\year
33 \expandafter\xint_gobble_i\the\numexpr100+\month\relax
34 \expandafter\xint_gobble_i\the\numexpr100+\day\relax
35 _%
36 \expandafter\xint_gobble_i\the\numexpr(\time+30)/60+99h%
37 \expandafter\xint_gobble_i\the\numexpr100+\time-60*((\time+30)/60-1).tex}%
38 \immediate\openout\xs_out=\xs_name\relax
39 \begingroup\catcode37 12
40 \long\gdef\xs_message#1{\message{#1$$J}\immediate\write\xs_out{%#1}}\endgroup%$$
41 {\catcode13\active\def
42 {$$J}\catcode32\active\let \space%$$
43 \catcode`?=0\catcode`\\=12\relax%
44 ?xdef?xs_logo{%
45 _____ _____
46 ____ ____(_)________ /_________ _________________
47 __ |/_/_ /__ __ \ __/ _ \_ |/_/__ __ \_ ___/
48 __> < _ / _ / / / /_ / __/_> < __ /_/ / /
49 /_/|_| /_/ /_/ /_/\__/ \___//_/|_| _ .___//_/
50 /_/
51 _____ _____ __________ ______
52 ___(_)________ /__________________ ________ /___(_)__ ______ / /
53 __ /__ __ \ __/ _ \_ ___/ __ `/ ___/ __/_ /__ | / / _ \ /_/
54 _ / _ / / / /_ / __/ / / /_/ // /__ / /_ _ / __ |/ // __/__
55 /_/ /_/ /_/\__/ \___//_/ \__,_/ \___/ \__/ /_/ _____/ \___//_/%
56 }%
57 ?xdef?xs_copyright{%
58 xintsession 0.4alpha (2021-11-01)
59 Copyright (c) Jean-Francois Burnol, 2021.%
60 }}%
61 \def\xs_no{0}%
62 \XINT_expr_defvar_one{@___}{{0}}%
63 \XINT_expr_defvar_one{@__}{{0}}%
64 \XINT_expr_defvar_one{@_}{{0}}%
65 \def\xs_prime_invite{>>> }%
66 \def\xs_second_invite{... }%
67 \def\xs_fetch
68 {%
69 \let\xs_in\empty
70 \let\xs_invite\xs_prime_invite
71 \xs_fetch_aa
72 }%
73 \def\xs_fetch_aa
74 {%
75 \message{\xs_invite}\read-1to\xs_buf
76 \expandafter\xs_fetch_a\xs_buf\xs_fetch_a
77 }%
78 \long\def\xs_fetch_a#1\xs_fetch_a
79 {%
80 \odef\xs_firstitem{\romannumeral0\xintfirstitem{#1.}}%
81 \ifcat\relax\expandafter\noexpand\xs_firstitem
82 \expandafter\xs_cs
83 \else
84 \if &\expandafter\noexpand\xs_firstitem
85 \expandafter\expandafter\expandafter\xs_magic
86 \fi
87 \fi
88 \if;\expandafter\noexpand\romannumeral0\xintlastitem{#1}%
89 \xs_fetch_b#1^%
90 \else
91 \odef\xs_in{\xs_in#1}%
92 \let\xs_invite\xs_second_invite
93 \expandafter\xs_fetch_aa
94 \fi%
95 }%
96 \long\def\xs_cs\if;\expandafter\noexpand\romannumeral0\xintlastitem#1#2\fi
97 {%
98 \xs_message{(executing \detokenize{#1} in background)}%
99 % potential problems if a group is closed by #1.
100 % should I issue \xs_resetenv here ?
101 #1%
102 \message{$$J}\xs_fetch_aa%$$
103 }%
104 \def\xs_firstfour#1#2#3#4#5\xint_bye{\edef\xs_magic_in{#1#2#3#4}\def\xs_magic_inb{#5}}%
105 \long\def\xs_magic\if;\expandafter\noexpand\romannumeral0\xintlastitem#1#2\fi
106 {%
107 \xs_firstfour#1\empty\empty\empty\empty\xint_bye
108 \ifcsname xs_magic@\xs_magic_in\endcsname
109 \csname xs_magic@\xs_magic_in\expandafter\endcsname
110 \else
111 \xs_message{(\detokenize\expandafter{\xint_gobble_i#1} is not a magic keyword:
112 ignored)$$J}%$$
113 \fi
114 \xs_fetch_aa
115 }%
116 \long\def\xs_fetch_b#1;^%
117 {%
118 \odef\xs_in{\xs_in#1}\expandafter\xs_fetch_c
119 }%
120 \def\xs_fetch_c
121 {%
122 \if\relax\romannumeral`$$@\detokenize\expandafter{\xs_in}\relax\expandafter\xs_pause\fi%$$
123 \expandafter\xs_parse_a\xs_in:=^%
124 }%
125 \def\xs_pause\expandafter\xs_parse_a\xs_in:=^{\xs_pause_a\xs_fetch_aa}%
126 \def\xs_pause_a\xs_fetch_aa
127 {%
128 \xs_message{Need a break? OK, use \string\xintsession\space if you change your mind.}%
129 \xs_resetenv
130 }%
131 \def\xs_bye\xs_fetch_aa
132 {%
133 \xs_message{Did I say something wrong?}%
134 \xs_message{Session transcript written on \xs_name}%
135 % \xs_resetenv
136 \immediate\closeout\xs_out
137 % expeditive exit because I need to think about generating new output
138 % filename with a check that it is not same (a minute may be too coarse?).
139 % Add random postfix? or simply do not bother rather...
140 \csname bye\endcsname
141 }%
142 \def\xs_parse_a#1:=#2%
143 {%
144 \xint_gob_til_^#2\xs_calc ^%
145 \def\xs_left{#1}\xs_parse_b#2%
146 }%
147 \def\xs_calc ^#1^%
148 {%
149 \edef\xs_no{\the\numexpr1+\xs_no}%
150 \xs_xintdefvar @_\xs_no=\xs_in;%
151 \immediate\write\xs_out
152 {\expandafter\string\xs_xintdefvar\space @_\xs_no:=%
153 \detokenize\expandafter{\xs_in};}%
154 \XINT_expr_defvar_one{@___}{\XINT_expr_varvalue_@__}%
155 \XINT_expr_defvar_one{@__}{\XINT_expr_varvalue_@_}%
156 \XINT_expr_defvar_one{@_}{\csname XINT_expr_varvalue_@_\xs_no\endcsname}%
157 \xs_message{%
158 @_\expandafter\xs_keepsix\xs_no\space\space\space\space\space\relax
159 \xs_xinteval{@_\xs_no}%
160 }%
161 \xs_fetch
162 }%
163 \def\xs_keepsix#1#2#3#4#5#6#7\relax{#1#2#3#4#5#6}%
164 \def\xs_parse_b #1:=^%
165 {%
166 \def\xs_right{#1}\expandafter\xs_parse_c\xs_left(;%
167 }%
168 \def\xs_parse_c #1(#2%
169 {%
170 \edef\xs_funcname{\expandafter\xint_zapspaces\detokenize{#1} \xint_gobble_i}%
171 \xint_gob_til_sc#2\xs_defvar;\xs_deffunc
172 }%
173 \edef\xs_fourspaces{\space\space\space\space}%
174 \def\xs_deffunc #1;%
175 {%
176 % attention: \xs_xintdeffunc needs to see parentheses immediately
177 \expandafter\xs_xintdeffunc\xs_left=\xs_right;%
178 \immediate\write\xs_out
179 {\expandafter\string\xs_xintdeffunc\space\detokenize\expandafter{\xs_left}:=%
180 \detokenize\expandafter{\xs_right};}%
181 \expandafter\ifx\xs_xintdeffunc\poldef
182 \xs_message{\xs_funcname\space = \PolToExpr{\xs_funcname}}%
183 \xs_message{\xs_fourspaces -->
184 &GenFloat(\xs_funcname) lets
185 \xs_funcname\space become usable as function in fp mode}%
186 \xs_message{\xs_fourspaces
187 --> &ROOTS(\xs_funcname) (resp. &ROOTS(\xs_funcname,N))
188 finds all rational roots exactly and}%
189 \xs_message{\xs_fourspaces\xs_fourspaces
190 all irrational roots with at least
191 \xintsessiondefaultrootsprecision\space(resp. N)
192 fractional digits}%
193 \else\xs_message{Function \xs_funcname\space defined}%
194 \fi\xs_fetch
195 }%
196 \def\xs_defvar;\xs_deffunc
197 {%
198 \edef\xs_no{\the\numexpr1+\xs_no}%
199 \xs_xintdefvar @_\xs_no=\xs_right;%
200 \immediate\write\xs_out
201 {\expandafter\string\xs_xintdefvar\space\detokenize\expandafter{\xs_left}:=%
202 \detokenize\expandafter{\xs_right};}%
203 \XINT_expr_defvar_one{@___}{\XINT_expr_varvalue_@__}%
204 \XINT_expr_defvar_one{@__}{\XINT_expr_varvalue_@_}%
205 \XINT_expr_defvar_one{@_}{\csname XINT_expr_varvalue_@_\xs_no\endcsname}%
206 % this is to allow multiple assignments
207 \expandafter\xs_xintdefvar\xs_left=@_\xs_no;%
208 \xs_message{%
209 @_\expandafter\xs_keepsix\xs_no\space\space\space\space\space\relax
210 \xs_xinteval{@_\xs_no}%
211 }%
212 \xs_fetch
213 }%
214 \let\xs_magic@&pau\xs_pause_a
215 \let\xs_magic@&bye\xs_bye
216 \def\xs_magic@&fp
217 {%
218 \xs_message{fp mode (\xinttheDigits\space digits)}%
219 \def\xs_mode{fp (Digits=\xinttheDigits)}%
220 \def\xs_xintdefvar{\xintdeffloatvar}%
221 \def\xs_xintdeffunc{\xintdeffloatfunc}%
222 \def\xs_xinteval{\xintfloateval}%
223 }%
224 \expandafter\def\csname xs_magic@&fp=\endcsname
225 {%
226 \xintDigits*:=\xs_magic_inb\relax
227 \xs_message{fp mode (log and trig reloaded at Digits=\xinttheDigits)}%
228 \def\xs_mode{fp=\xinttheDigits}%
229 \def\xs_xintdefvar{\xintdeffloatvar}%
230 \def\xs_xintdeffunc{\xintdeffloatfunc}%
231 \def\xs_xinteval{\xintfloateval}%
232 }%
233 \def\xs_magic@&exa
234 {%
235 \xs_message{exact mode (floating point evaluations use \xinttheDigits\space digits)}%
236 \def\xs_mode{exact}%
237 \def\xs_xintdefvar{\xintdefvar}%
238 \def\xs_xintdeffunc{\xintdeffunc}%
239 \def\xs_xinteval{\xinteval}%
240 }%
241 \def\xs_magic@&int
242 {%
243 \xs_message{int mode (integer only: / rounds, // is floored division, /: is
244 modulo)}%
245 \def\xs_mode{int}%
246 \def\xs_xintdefvar{\xintdefiivar}%
247 \def\xs_xintdeffunc{\xintdefiifunc}%
248 \def\xs_xinteval{\xintiieval}%
249 }%
250 \def\xs_magic@&pol
251 {%
252 \xs_message{pol mode (i.e. function definitions use \string\poldef)}%
253 \def\xs_mode{pol}%
254 \def\xs_xintdefvar{\xintdefvar}%
255 \def\xs_xintdeffunc{\poldef}%
256 \def\xs_xinteval{\xinteval}%
257 }%
258 \def\xs_magic@&mod{\xs_message{current mode: \xs_mode}}%
259 \def\xs_getpolname#1(#2#3)#4\xint_bye{\edef\xs_polname{\xint_zapspaces #2#3 \xint_gobble_i}}%
260 \def\xs_magic@&Gen
261 {%
262 \expandafter\xs_getpolname\xs_magic_inb\xint_bye
263 \PolGenFloatVariant{\xs_polname}%
264 \immediate\write\xs_out{\string\PolGenFloatVariant{\xs_polname}}%
265 \xs_message{Polynomial function \xs_polname\space for &fp mode usage now defined}%
266 }%
267 \def\xintsessiondefaultrootsprecision{10}%
268 \def\xs_getpolandE#1(#2#3)#4\xint_bye
269 {%
270 \xs_getpolandE_i#2#3,,\xint_bye
271 }%
272 \def\xs_getpolandE_i#1,#2,#3\xint_bye
273 {%
274 \edef\xs_polname{\xint_zapspaces #1 \xint_gobble_i}%
275 \edef\xs_rootsprecision{\if\relax#3\relax
276 \xintsessiondefaultrootsprecision\else
277 \xint_zapspaces #2 \xint_gobble_i\fi}%
278 }%
279 \expandafter\def\csname xs_magic@&ROO\endcsname
280 {%
281 \expandafter\xs_getpolandE\xs_magic_inb\xint_bye
282 \xs_message{Solving for real roots of \xs_polname\space and assigning them (please wait...)}%
283 \PolToSturm{\xs_polname}{@\xs_polname}%
284 \PolSturmIsolateZerosGetMultiplicitiesAndRationalRoots{@\xs_polname}%
285 \PolEnsureIntervalLengths{@\xs_polname}{-\xs_rootsprecision}%
286 \immediate\write\xs_out{\string\PolToSturm{\xs_polname}{@\xs_polname}}%
287 \immediate\write\xs_out{\string\PolSturmIsolateZerosGetMultiplicitiesAndRationalRoots{@\xs_polname}}%
288 \immediate\write\xs_out{\string\PolEnsureIntervalLengths{@\xs_polname}{-\xs_rootsprecision}}%
289 \immediate\write\xs_out{\string\PolPrintIntervals{@\xs_polname}}%
290 \xs_polprintintervals
291 \xs_message{Square-free irrational part: \PolToExpr{@\xs_polname _sqf_norr}}%
292 \ifnum\PolSturmNbOfIsolatedZeros{@\xs_polname}>\PolSturmNbOfRationalRoots{@\xs_polname}
293 \xs_message{\xs_fourspaces -->
294 &REFINEROOTS(\xs_polname,N) to extend real irr. roots to N fractional digits}%
295 \else
296 \xs_message{No irrational real roots.}%
297 \fi
298 }%
299 \expandafter\def\csname xs_magic@&REF\endcsname
300 {%
301 \expandafter\xs_getpolandE\xs_magic_inb\xint_bye
302 \xs_message{Refining real roots of \xs_polname\space to \xs_rootsprecision\space
303 digits (please wait...)}%
304 \PolEnsureIntervalLengths{@\xs_polname}{-\xs_rootsprecision}%
305 \immediate\write\xs_out{\string\PolEnsureIntervalLengths{@\xs_polname}{-\xs_rootsprecision}}%
306 \immediate\write\xs_out{\string\PolPrintIntervals{@\xs_polname}}%
307 \xs_polprintintervals
308 }%
309 \def\xs_polprintintervals
310 {%
311 \begingroup\xintglobaldefstrue
312 \def\PolPrintIntervalsNoRealRoots{\xs_message{No real roots.}}%
313 \let\PolPrintIntervalsBeginEnv\empty
314 \let\PolPrintIntervalsEndEnv\empty
315 \def\PolPrintIntervalsKnownRoot{\PolPrintIntervalsPrintExactZero}%
316 \def\PolPrintIntervalsUnknownRoot{\xintifSgn{\PolPrintIntervalsTheLeftEndPoint}%
317 {\PolPrintIntervalsPrintRightEndPoint}%
318 {\PolPrintIntervalsPrintLeftEndPoint}%
319 {\PolPrintIntervalsPrintLeftEndPoint}%
320 }%
321 \def\PolPrintIntervalsPrintExactZero
322 {\xs_message{(mult. \PolPrintIntervalsTheMultiplicity)
323 Root\xs_polname _\PolPrintIntervalsTheIndex\space = \PolPrintIntervalsTheLeftEndPoint}%
324 \immediate\write\xs_out{\string\xintdefvar\space
325 Root\xs_polname _\PolPrintIntervalsTheIndex:=\PolPrintIntervalsTheLeftEndPoint;}%
326 \XINT_expr_defvar_one{Root\xs_polname _\PolPrintIntervalsTheIndex}%
327 {{\xintRaw{\PolPrintIntervalsTheLeftEndPoint}}}%
328 }%
329 \def\PolPrintIntervalsPrintLeftEndPoint
330 {\xs_message{(mult. \PolPrintIntervalsTheMultiplicity)
331 Root\xs_polname _\PolPrintIntervalsTheIndex\space = \PolPrintIntervalsTheLeftEndPoint...}%
332 \immediate\write\xs_out{\string\xintdefvar\space
333 Root\xs_polname _\PolPrintIntervalsTheIndex:=\PolPrintIntervalsTheLeftEndPoint;}%
334 \XINT_expr_defvar_one{Root\xs_polname _\PolPrintIntervalsTheIndex}%
335 {{\xintRaw{\PolPrintIntervalsTheLeftEndPoint}}}%
336 }%
337 \def\PolPrintIntervalsPrintRightEndPoint
338 {\xs_message{(mult. \PolPrintIntervalsTheMultiplicity)
339 Root\xs_polname _\PolPrintIntervalsTheIndex\space = \PolPrintIntervalsTheRightEndPoint...}%
340 \immediate\write\xs_out{\string\xintdefvar\space
341 Root\xs_polname _\PolPrintIntervalsTheIndex:=\PolPrintIntervalsTheRightEndPoint;}%
342 \XINT_expr_defvar_one{Root\xs_polname _\PolPrintIntervalsTheIndex}%
343 {{\xintRaw{\PolPrintIntervalsTheRightEndPoint}}}%
344 }%
345 \def\POL@PrintIntervals@Loop{%
346 \POL@SturmIfZeroExactlyKnown\PolPrintIntervalsTheSturmName\PolPrintIntervalsTheIndex
347 \PolPrintIntervalsKnownRoot
348 \PolPrintIntervalsUnknownRoot
349 \xdef\PolPrintIntervalsTheIndex{\the\numexpr\PolPrintIntervalsTheIndex+\@ne}%
350 \unless\ifnum\PolPrintIntervalsTheIndex>
351 \@nameuse{POL_ZL\PolPrintIntervalsTheSturmName*0}
352 \POL@PrintIntervals@DoDefs
353 \expandafter\POL@PrintIntervals@Loop
354 \fi
355 }%
356 \PolPrintIntervals{@\xs_polname}%
357 \endgroup
358 }%
359 \def\xs_setenv
360 {%
361 \newlinechar10\endlinechar-1\errorcontextlines0\relax
362 }%
363 \def\xs_storeenv{\edef\xs_resetenv
364 {%
365 \newlinechar\the\newlinechar
366 \endlinechar\the\endlinechar
367 \errorcontextlines\the\errorcontextlines
368 }}%
369 \def\xintsession
370 {\let\xintsession\xintsessionresume
371 \xs_setenv\xint_welcome\message{Starting in}\xs_magic@&exa\xs_fetch}%
372 \def\xintsessionresume
373 {\xs_storeenv\xs_setenv\xs_welcome_back\xs_fetch}%
374 \begingroup
375 % some things here are weird but this was initially to make the 0.3 transition
376 % to usage of \read-1 in place of active ^^M with minimal collateral changes
377 % the active ^^M here is now reduced to avoid to have to type explicit ^^J in the
378 % definition of the help messages
379 \catcode13\active\catcode32\active%
380 \let \space% this is Plain default anyhow
381 \def
382 {$$J}%$$
383 \xdef\xint_welcome{\noexpand\message{\xs_copyright
384 Welcome to
385 \xs_logo
386
387 - input is `;'-terminated and can extend over multiple lines
388 - definitions of variables and functions are done with `:='.
389
390 \string\jobname is \jobname
391 Transcript will go to log and to \xs_name
392 Typing at the prompt
393 - `&pause' or `;' exits to normal TeX (typesetting) interaction,
394 - `&bye' terminates the session,
395 - `&help' triggers help panels,
396 - `&exact', `&fp', `&int', or `&pol' switches among modes.
397 }}%
398 \xdef\xs_welcome_back{\noexpand\message{%
399 You are back to the xintexpr interactive session!
400 (current mode: \noexpand\xs_mode, with Digits=\noexpand\xinttheDigits)
401
402 ">>> " means central computing is waiting for input
403 "... " means that multi-line input continues. Use `;' to terminate it.
404
405 Say `&bye' at any time to terminate the session and the TeX run.
406 }}%
407 \catcode`?0\catcode`\\12\relax%
408 ?xdef?xs_help_message_i{%
409 - Terminate inputs with the `;' character. Inputs can extend over
410 multiple lines (each terminated by <return>).
411
412 - An empty input (`;' terminated) or the magic word `&pause' puts
413 the session on hold and switches to normal TeX interaction, with
414 its `*' prompt. Use \xintsession to resume the session.
415
416 - Lines starting with any control sequence are handed over to
417 TeX (no end of line space token is included), and the current
418 numerical input resumes on next line.
419
420 - The computing kernel can work in various modes:
421 exact (uses \xintexpr), fp (uses \xintfloatexpr), int (uses
422 \xintiiexpr), and pol (makes definitions using \poldef).
423 To activate a mode enter `&<mode name>' at the prompt
424
425 - Issue `&mode' if you forgot in what mode you are currently in.
426
427 (1/5) say `n' (or directly <return>) for next, `q' to quit, or one of
428 `2', `3', `4', or `5' to jump directly to corresponding panel.
429 }%
430 ?xdef?xs_help_message_ii{%
431 - Say `&exact' resp. `&fp' to go back and forth between exact
432 and floating point mode
433
434 - Say `&fp=<number>' for example `&fp=32' at the prompt to activate
435 fp mode at a given Digits setting. This can be done in the midst
436 of the input of a multi-line computation!
437
438 - Math functions are supported up to Digits=62 (since xint 1.4e);
439 sqrt() and powers with integer exponents work in fp mode with Digits
440 arbitrary.
441
442 - Definitions (variables or functions) are done using `:='.
443
444 * Parentheses present before the `:=' trigger a function
445 definition, else a variable definition is done.
446
447 * IMPORTANT: using a `=' by oversight will cause breakage as
448 xintsession thinks it is handling an evaluation, not a definition.
449
450 % Perhaps in future it will be allowed to make definitions using `='
451 % and xintsession will check if it is not misinterpreting a `=' from
452 % `<=', `>=', `!=', `==' or `seq()' syntax but this currently was
453 % considered to add too much overhead for the benefit.
454 %
455 (2/5) say `n' (next), `p' (previous), `q' (quit), or one of `1' to `5'.
456 }%
457 ?xdef?xs_help_message_iii{%
458 - Functions defined in one mode are not available for usage in
459 other modes without further steps; check xintexpr doc.
460
461 - Polynomials in pol mode are defined using polname(x):=expression;
462 (or with another letter). They can serve as functions in the exact
463 mode. To use a polynomial also as an fp mode function, issue
464 &GenFloat(<polname>) at the prompt.
465
466 - Whenever a variable is defined, or a computation is performed,
467 the result is assigned a label @_<integer>. These labels are
468 variables which can then be used in subsequent computations.
469
470 - The special variables @_, @__, and @___ hold the last, next
471 to last and next to next to last evaluation results.
472
473 - In the case of a multi-variable assignment (see xintexpr doc)
474 the automatic variable @_<integer> holds the whole thing, which
475 may be a nutple or an ople, in addition to individual variables.
476
477 (3/5) say `n' (next), `p' (previous), `q' (quit), or one of `1' to `5'.
478 }%
479 ?xdef?xs_help_message_iv{%
480 - Variables defined in any mode can be used in any mode except:
481 * polynomials can be used as variables only in the pol and the
482 exact modes,
483 * integer-only mode requires... integer-only variables, also
484 internally. Use num() or \xintiexpr...\relax as wrappers in int
485 mode around exact or fp variables (even integer-valued ones).
486
487 Known issues:
488
489 - The [P] optional argument of \xintfloateval can not be used
490 because it is not recognized by \xintdeffloatvar, one can use
491 the float() function with its second argument.
492
493 - An \xintexpr...\relax wrapper can not start a line, as it would
494 trigger control sequence execution. Use parentheses or 0+\...
495
496 - Exact mode does not reduce to lowest terms, use reduce().
497
498 (4/5) say `n' (next), `p' (previous), `q' (quit), or one of `1' to `5'.
499 }%
500 ?xdef?xs_help_message_v{%
501 (cont.)
502 - A session transcript file is created which can be executed by
503 eTeX to redo all calculations; however @_, @__, and @___ will
504 not be defined in this context so need to be manually replaced
505 by the suitable @_<integer>. The format of the transcript
506 is to be considered unstable at this stage.
507
508 Future:
509
510 - a plot() function will be added at some point to export
511 coordinates into a .tex file for usage either with PSTricks or
512 TikZ/pgf.
513
514 Miscellany:
515
516 Some exceptions are caught by xintexpr itself: enter <return> at
517 the prompt and a recovery will be attempted. If deep in core
518 TeX errors, try escaping using `S'. It does work sometimes.
519
520 (5/5) say `p' (previous), `q' (quit), or one of `1' to `5'.
521 }%
522 ?endgroup
523 \def\xs_help\xs_fetch_aa{\xs_help_i}%
524 \def\xs_help_i
525 {%
526 \message{\xs_help_message_i}%
527 \def\xs_help_next##1\xs_help_next
528 {%
529 \if\xintFirstItem{##1n}n\xint_dothis\xs_help_ii\fi%
530 \ifnum10<1\expandafter\string\romannumeral0\xintfirstitem{##1}\relax%
531 \xint_dothis{\csname xs_help_\romannumeral\xintFirstItem{##1}\endcsname}\fi%
532 \xint_orthat\xs_help_quit
533 }%
534 \message{n, q, or 1 to 5: }%
535 \read-1to\xs_tmp\expandafter\xs_help_next\xs_tmp\xs_help_next
536 }%
537 \def\xs_help_ii
538 {%
539 \message{\xs_help_message_ii}%
540 \def\xs_help_next##1\xs_help_next
541 {%
542 \if\xintFirstItem{##1n}n\xint_dothis\xs_help_iii\fi%
543 \if\xintFirstItem{##1}p\xint_dothis\xs_help_i\fi%
544 \ifnum10<1\expandafter\string\romannumeral0\xintfirstitem{##1}\relax%
545 \xint_dothis{\csname xs_help_\romannumeral\xintFirstItem{##1}\endcsname}\fi%
546 \xint_orthat\xs_help_quit
547 }%
548 \message{n, p, q, or 1 to 5: }%
549 \read-1to\xs_tmp\expandafter\xs_help_next\xs_tmp\xs_help_next
550 }%
551 \def\xs_help_iii
552 {%
553 \message{\xs_help_message_iii}%
554 \def\xs_help_next##1\xs_help_next
555 {%
556 \if\xintFirstItem{##1n}n\xint_dothis\xs_help_iv\fi%
557 \if\xintFirstItem{##1}p\xint_dothis\xs_help_ii\fi%
558 \ifnum10<1\expandafter\string\romannumeral0\xintfirstitem{##1}\relax%
559 \xint_dothis{\csname xs_help_\romannumeral\xintFirstItem{##1}\endcsname}\fi%
560 \xint_orthat\xs_help_quit
561 }%
562 \message{n, p, q, or 1 to 5: }%
563 \read-1to\xs_tmp\expandafter\xs_help_next\xs_tmp\xs_help_next
564 }%
565 \def\xs_help_iv
566 {%
567 \message{\xs_help_message_iv}%
568 \def\xs_help_next##1\xs_help_next
569 {%
570 \if\xintFirstItem{##1n}n\xint_dothis\xs_help_v\fi%
571 \if\xintFirstItem{##1}p\xint_dothis\xs_help_iii\fi%
572 \ifnum10<1\expandafter\string\romannumeral0\xintfirstitem{##1}\relax%
573 \xint_dothis{\csname xs_help_\romannumeral\xintFirstItem{##1}\endcsname}\fi%
574 \xint_orthat\xs_help_quit
575 }%
576 \message{n, p, q, or 1 to 5: }%
577 \read-1to\xs_tmp\expandafter\xs_help_next\xs_tmp\xs_help_next
578 }%
579 \def\xs_help_v
580 {%
581 \message{\xs_help_message_v}%
582 \def\xs_help_next##1\xs_help_next
583 {%
584 \if\xintFirstItem{##1n}p\xint_dothis\xs_help_iv\fi%
585 \ifnum10<1\expandafter\string\romannumeral0\xintfirstitem{##1}\relax%
586 \xint_dothis{\csname xs_help_\romannumeral\xintFirstItem{##1}\endcsname}\fi%
587 \xint_orthat\xs_help_quit
588 }%
589 \message{p, q, or 1 to 5: }%
590 \read-1to\xs_tmp\expandafter\xs_help_next\xs_tmp\xs_help_next
591 }%
592 \def\xs_help_quit{\xs_welcome_back\xs_fetch}%
593 \let\xs_magic@&hel\xs_help\let\xs_help_vi\xs_help_quit\let\xs_help_vii\xs_help_quit
594 \let\xs_help_viii\xs_help_quit\let\xs_help_ix\xs_help_quit
595 %
596 \xsrestorecatcodes%
597 \csname xs\string _storeenv\endcsname\endlinechar13\relax%
598 % extremely eTeX-weird bug of 0.3 which had here \endinput\xintsession,
599 % causing breakage if the latter attempts a \scantokens in an \edef
600 % (which is what happens for function definitions).
601 % bugfix 0.3a by simply moving \xintsession to before the \endinput
602 \xintsession\endinput%