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:
Thu, 2 Feb 2012 13:18:44 +0000
Content-Type:
text/plain
Parts/Attachments:
text/plain (76 lines)
* Bruno Le Floch <[log in to unmask]> [2012-02-02 07:32:27 -0500]:

: Like Joseph, I don't see how useful the functions you propose are. Do
: you have a precise use case? I think that what you propose can be done
: (in the non-expandable case) as (say for the "some" version):
: 
:     \bool_set_false:N \l_my_bool
:     \tl_map_inline:Nn \l_my_tl
:       {
:         \my_conditional:nT {#1}
:           {
:             \bool_set_true:N \l_my_bool
:             \prg_map_break:
:           }
:       }
:     \bool_if:NTF \l_my_bool
:       { <my conditional was true at least once> }
:       { <my conditional was never true> }

Thanks Bruno. I have a question if you don't mind.

On stack exchange there's a question that asks how to compute some
values that satisfy a recurrence equation.

I'm currently implementing a macro that lets a user define these
recurrence equations and then generates a macro that solves the
recurrence. I'm trying to do this with expl3. Your regex module
has turned very useful. (This exercise is related to the pattern
matching programming I was referring to earlier.)

For example, at the moment, I can parse the following:
    \NewRecDef{myA}{a[0]=1,
                    a[1]=1,
                    a[i]=a[i-1]+a[i-2]}
The purpose of this macro call is to define a macro called \myA that
solves the recurrence. I've only just started and it works for
the base cases: \myA{0} -> 1 and \myA{1} -> 1. It's not much, but
it's a start:-)

I also want to be able to write:
    \NewRecDef{myA}{a[i]=1 | 0 <= i && i <= 1,
                    a[i]=[i-1]+a[i-2]}
which is equivalen to

    \NewRecDef{myA}{a[i]=1            | 0 <= i && i <= 1
                    a[i]=[i-1]+a[i-2] | true}

The parts after the | symbols are guards, which are conditions that
need to be satisfied before the computation rule can be applied.

Now here is the question. What I'd like to know if there's an easy way
for a substitution of the form
  a[expression] -> \csname myA[expression]\endcsname
If there is an easy way to do this than this simply lets me apply the
substitution to the guard expressions and they then give me the conditions
that need to be satisfied before I can return the ``result'' (the text
between the = and the |). Of course, I also have to make the substitution
in the result.

Any help would be much appreciated.

NOTES:
 o For the moment, I want to implement this for recurrence equations in
   one argument but implementing it for more arguments is techically
   equivalent.
 o Using an external program to generate the LaTeX is trivial. I've
   done similar things several times. the challenge is doing it from
   within LaTeX with expl3, l3regex, and l3int.
 o If this approach works, I think it may be a nice possible alternative
   for defining macros that depend on tokens and return tokens.

Regards,


Marc

ATOM RSS1 RSS2