Pointers and references: Difference between revisions
Content added Content deleted
Puppydrum64 (talk | contribs) |
(→{{header|PARI/GP}}: now with references!) |
||
Line 1,332: | Line 1,332: | ||
=={{header|PARI/GP}}== |
=={{header|PARI/GP}}== |
||
Some built-in functions like <code>issquare</code> have pointer arguments: |
|||
<lang parigp>n=1; |
<lang parigp>n=1; |
||
issquare(9,&n); |
issquare(9,&n); |
||
print(n); \\ prints 3</lang> |
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). |
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). |