Anonymous user
Pointers and references: Difference between revisions
→{{header|PARI/GP}}: now with references!
Puppydrum64 (talk | contribs) |
(→{{header|PARI/GP}}: now with references!) |
||
Line 1,332:
=={{header|PARI/GP}}==
<lang parigp>n=1;
issquare(9,&n);
print(n); \\ prints 3</lang>
{{Works with|PARI/GP|2.12.0}}
User functions and certain built-in functions (listput, listpop, mapput, etc.; all those with [http://pari.math.u-bordeaux.fr/dochtml/html-stable/usersch5.html#GP-prototypes-parser-codes parser code] W) can take arguments by reference with the prefix ~ operator:
<lang parigp>boxit(~L, x)=listput(L, x);
S=List();
boxit(S,1);
S</lang>
{{out}}
<pre>1</pre>
Pari program can use C pointers normally. In fact, all GEN variables are actually pointers to a space within the Pari stack (or, rarely, the Pari heap).
|