S. Gilles on Sat, 15 Jul 2017 00:40:10 +0200

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

fetch_user_var() doesn't behave as I expect


I wanted the following program to print "b=b, c=c", but unfortunately
it printed "b=b, c=a".

        #include <pari/pari.h>
        int main(void)
                pari_init(512 * 1024, 0);
                GEN a = varlower("a", 1);
                GEN b = gsubst(a, varn(a), varlower("b", 1));
                GEN c = gsubst(a, fetch_user_var("a"), varlower("c", 1));
                pari_printf("b=%Ps, c=%Ps\n", b, c);
                return 0;

Based on the manual's description of fetch_user_var(), I think this
might be a bug, but it is also quite probable that my understanding
of fetch_user_var() is incorrect.

Assuming my understanding is incorrect, is there a built-in function
that will take a string s (which could be something silly like
"1+1") and return the number of a variable I made earlier with e.g.
`varlower(s, 1)'?

S. Gilles