Karim BELABAS on Tue, 22 Oct 2002 12:38:52 +0200 (MEST)


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

Re: lists


On Mon, 21 Oct 2002, Olivier Ramare wrote:
>   Yes I know I shouldn't use lists but ...

Why ?

> {
> gep()=
>    local(myliste=listcreate(1000));
>    listput(myliste,123);
>    print(myliste)
> }
> ---------------------------------------------------
>                        GP/PARI CALCULATOR Version 2.1.4 (released)
>                      i686 running linux (ix86 kernel) 32-bit version
> [...]
> ? gep()
> List([123])
> ? gep()
> List([123, 123])

See COMPAT (2.1-->2.2):

  - Default args for user defined functions now evaluated when function is
    called (used to be: at definition time)
    E.g f(x) = local(z = x); z.
    Before: f(2) --> x
    Now:    f(2) --> 2

In short, your function definition is incorrect in 2.1.* branch
(listcreate is executed once, when gep() is defined). It works as you
expected since 2.2.1.

I'm not backporting this...

Cheers,

    Karim.
-- 
Karim Belabas                    Tel: (+33) (0)1 69 15 57 48
Dép. de Mathematiques, Bat. 425  Fax: (+33) (0)1 69 15 60 19
Université Paris-Sud             Email: Karim.Belabas@math.u-psud.fr
F-91405 Orsay (France)           http://www.math.u-psud.fr/~belabas/
--
PARI/GP Home Page: http://www.parigp-home.de/