Bill Allombert on Tue, 16 Apr 2024 23:15:50 +0200
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: simple question on why indice variables are not counted as variables for gp2c-run command
|
- To: pari-users@pari.math.u-bordeaux.fr
- Subject: Re: simple question on why indice variables are not counted as variables for gp2c-run command
- From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
- Date: Tue, 16 Apr 2024 23:15:43 +0200
- Arc-authentication-results: i=1; smail; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1713302148; c=relaxed/relaxed; bh=qsBheVCjaH5DSmsH8ca0Q99G2wG6L3cQU+O9pBV0PBI=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:Mail-Followup-To: References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; b=pES0P6gC3vvmqnDL0YA1wfvJQAn+JVqf2NkatHj6GmJWX9aEMn4uoo5T/u7Nx0owJBkd/NAXm/kiSbNahbPvTrIEzFonH9lIAwjUAzIOO4+zpCbezp0f0jSAxWpaBOo9X4IM+ke9egA/V5ffjYLtnVGPushViyJkNHhFMeA2coOdLCu+ya4y7uhLnyDUJ4O0Z8HgJMrn+O5qk4fZyvi9ZiQHRE3dy2yTVoDxehG7r7UbB+aU+r5vsx/88pGqAHdxb6ny6VS5D5ja1q/7jFfxvBMFPyz7SU3KkaMkU3qCtvDh9yWLHs4Ce3yBNFUkC16P3nkz27riZ9b/+9hmD1JrCS8ywc+L4/CN+c0UCazKZO0gaHVT5HI65b5Rm7fIT5MxKIvm4Ym/TOlyLizKOQfNl8hSvU9DPEALE8juF2Dm56NaRASH0FalYE+H+gZLC2lxaaeRjcVbyswtYtDzQU+MCqhfhJmJKGJwGyqVUA09dDrETmY2LSlPc0ocdGP5V68pRKw32DF5WZPlWpu9K52TFCPHMuiC/o7ueigZ1C1Nct2QX8X91Yv6B+6OsFKX6BaBPygsfbwIFYwKjYWHMCMNmQFwcqUwko9Z8Td1ZKTeNk5OrujwdVdbF4UtWxskPqCJyevfTKAKqvygDWD0j+jMdBzG+xnlYUUEIAxc+HC5uEU=
- Arc-seal: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1713302148; cv=none; b=P1Lbhf0g/Tg3tWnZN8B2sVi0qmRNKDRlBle4Ves1T/rzc+ZBeri79ldyzHApp4vTGYBPeiuEqYrrLrAtFdObJpTzx0Nbx2y1tcIVeWJ9AVOE76meu93GyZ36fTdB0A7ss3JdGw1re84YyJTSJlgqqXP3JJDbABULJaPGCTb85SKZtXkedUv6IjuabJfkp/KpVW/k3keL5eIgRT7Yu51MHrKuVwTwKcimjEcj4BpMw4mSNf1AgigcRhDy2ZaiVCN8zx3Wyt3xS+XZ19ap1+WotJ0EjUnXMZbrpcVZWjjEMfmLoeP3upE0/JbwLH0e4VDe8Utxixx69UVjElo4lYBqMNmjK6ikemCSB51i97m8GJ//FJsRRdgo6iAnTLymJ+GEWgoXhIoLnsMcqG0vhfL/EWjNouUKHx5qUSZbsUnD+GV535tNbgPnalA8IlhGZrlDPyw1Rx0v596USpZQcDVtKrzS9Jo9l9g7MkebIlmePDRLDrMKDOXKZtc9QesIj2etKaaYTtGGDAf+3fjvG6CmIUSW/MBPZQykz2t6zQKkIr7IGMa/lr+HVR+Hk8vkrQlB57Bw3EHRMnsOfG2USAPKQN7KaogKSUcjWTy3w1td+TnyFI3CGG9BiZnE8yDMQWDGeSPr63QVyEEZbcpnQXFiPhvf6QXiIIpf/xMq8A3j4Ps=
- Authentication-results: smail; dmarc=none header.from=math.u-bordeaux.fr
- Authentication-results: smail; arc=none
- Delivery-date: Tue, 16 Apr 2024 23:15:51 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=math.u-bordeaux.fr; s=2022; t=1713302148; bh=qsBheVCjaH5DSmsH8ca0Q99G2wG6L3cQU+O9pBV0PBI=; h=Date:From:To:Subject:References:In-Reply-To:From; b=tavC6mihoEFYE5/bOMXrT5reJIWQW0a0a/IQ3CsCMZ4+MzwEc6ktqDIFPJXLmF5E9 Ap1TjZTNUdYdcyoqR+z3zIEc7rS98b/NnMdMItyn+WeBLeQ8YJ0cdEPyHtffALh46n zyPPcU7hBn5uyClTqWWsvWyJqjT/RUY6CA3PT26dgHYn6ecsW1PJczSjgqhhs6sXaz qFnxXqSSdxpPZJ+BTDeIDbA2QDl6g1JFenOSegYdjmBjwSjb0deX5xILzTkc/fAKCN YdFxM9s0U4EBTeeUbVfLu8IAPb/ixK+4Btukojn0pWI4JQikr6ybxul/wfcFUshCci h4Ogvoau4s18WgDgmFWf280QcIUUlo9PpjU5qyty/afrzGTtU8rlr992PDsJv0K4dH pXhOxbTK2g1u+xGholDBd6BIcCS7LkwvEbxRkKmbnsLJGehJduB5kExi0Qx8wMIuU7 WD5W7d2f5WrZaGsVMCAeUfRes+hUcKUVE7ZEoGo1Ke0eaams661iAKDlKovRcCHsdk /xwgqMb3fHoQoniYetK9jzWQzSNUC8uTWa/b0mb7bdQKt1O3CoECD3rNYnER6f3482 hrY0vIObqA3LzNQrMkMsaL8Jr1psrxROlDdBgsUeL6ML35nnkurKkiYHp9ADqFW5Q0 mUV06+6Ec97A/IDFaztunQng=
- In-reply-to: <800c32b4-7982-409a-bb67-8fb8ad0f2faa@gmail.com>
- Mail-followup-to: pari-users@pari.math.u-bordeaux.fr
- References: <800c32b4-7982-409a-bb67-8fb8ad0f2faa@gmail.com>
On Tue, Apr 16, 2024 at 12:20:08PM -0700, American Citizen wrote:
> I have a simple question here,
>
> Let test_fun.gp be a simple script file (basically doing nothing)
>
> {test_fun(n)=
> local(i,j,x);
> for(i=1,n-1,
> for(j=i+1,n,
> x=x;
> );
> );
> return(0);
> }
>
> Is the c-compiler purposefully ignoring the i,j as index variables in the
> loop?
In PARI/GP, doing for(i=... actually declares i as a local variable to the loop.
so local(i) is declaring another variable i, which is not used.
Try this example;
? fun(x)=my(i=0);for(i=1,x,if(i^2>x,print(i);break));i;
? fun(100)
11
%4 = 0
Also I advise to use my() instead of local() unless you have specific reason.
my() variable are statically-scoped, which is less likely to cause bugs.
Cheers,
Bill