LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Reply To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Date:
Sun, 5 Feb 2012 16:08:26 +0000
Content-Type:
multipart/mixed
Parts/Attachments:
text/plain (1848 bytes) , recurrence.tex (675 bytes) , recurrence.sty (4 kB)
* Bruno Le Floch <[log in to unmask]> [2012-02-03 15:01:01 -0500]:

: > : All LaTeX3 functions are either fully expandable or engine-protected. In
: > : this case, we are talking about protected functions: these are not
: > : expandable. (In the documentation, expandable functions are marked with
: > : a star.)
: 
: Joseph is right. Regular expression matching is already tough enough
: to not try to do it expandably (besides, that would become
: unreasonably slow, and would break in corner cases). What you seem to
: be trying can be done as follows instead:

Hi again,


I've made some progress with the recurrence equations, but I have a error
that I don't understand. I'd appreciate it if you could have a quick look.

Given the standard (naive) definition of the Fibonacci numbers (f[0]=1,
f[1]=1,f[i]=f[i-1],f[i-2]), my code generates the following artificial
macros:

\f macro:#1->\f:n {#1}
\f:n macro:#1->\exp_args:Nx \recurrence_f_0:x {\int_eval:n {#1}}
\recurrence_f_0:x macro:#1->\int_compare:nTF {#1=0}{1}{\recurrence_f_1:x {#1}}
\recurrence_f_1:x macro:#1->\int_compare:nTF {#1=1}{1}{\recurrence_f_2:x {#1}}
\recurrence_f_2:x macro:#1->\bool_if:nTF {\int_compare_p:n{1=1}}{\f:n{#1-1}+\f:n{#1-2}}{\recurrence_f_3:x {#1}}
\recurrence_f_3:x \long macro:#1->\error {f[ #1 ] undefined.}

The macros \f and \f:n are wrappers. The macros \recurrence_f_0, ...,
\recurrence_f_2 deal with the three different conditions, and
\recurrence_f_3 deals with errors, which cannot occur here, but
in general cases may not be matched.

Computing \f{0} and \f{1} works fine, but evaluating \f{2} doesn't.

The current code I have is packaged as a .tex and a .sty file. If you have
any comments on the problem, or indeed, the source files, then that'd be
much appreciated.

I've tried to keep the code simple. Optimising can be done later.

I'm attaching the source files.

Regards,


Marc van Dongen


ATOM RSS1 RSS2