1.1.11 Tutorial: defining new functions (advanced) |
Example |
/**/ define negate(ref X) // pass by reference /**/ X := -X; // changes value of variable OUTSIDE the fn /**/ enddefine; // does not "return" a value, so is a procedure! /**/ A := 1; /**/ negate(ref A); // use "ref" also to call the fn /**/ println A; // now see that value has changed -1 /**/ define QQx() /**/ TopLevel QQ; // make global variable QQ accessible /**/ return NewPolyRing(QQ, "x"); /**/ enddefine; /**/ QQx(); RingWithID(3, "QQ[x]") |