|  Try GP in your browser Main Download Packages Funding SEARCH Help / Community FAQ Documentation Tutorials Mailing Lists Bugs Timeline Ateliers PARI/GP Library Publications Contributed GP scripts Links Fun! Development Latest Changes Version Control Coding Guidelines PariDroid Logo Tests & benchmarks Buildlogs Coverage Report Doc Coverage Refcards test Benchmarks WWW Stats | How to use extern: the example of mwrank
The  
Unfortunately, using  
We assume henceforth that you have a working version of  
 mwrank. And similarly the output
ofmwrankwith proper flags follows the GP syntax.
In more complicated cases, one would also need a wrapper script converting GP
data to the format expected by the external program, and the program's output
to GP syntax. This is easily done in Bash, Perl or Python, but beyond the
scope of this document.Wrapper gpscriptIn order to define the functionmwrank, create a filemwrank.gpcontaining the following lines:
  mwrank(E)=
  {
    my(cmd=Str("echo '", E[1..5], "' | mwrank -q -o -v 0"));
    eval(externstr(cmd)[2]);
  }
This calls  Put this file somewhere in your GP path. (See the path default in the manual.) Loading mwrank on startupAdd the following line at the end of your.gprcfile:
    read "mwrank.gp"
This causes the  
Of course, the names of the file and function do not have to coincide. They
were chosen as above for consistency and self-documentation:
 
    path = "$HOME/pari/gpscripts"
in your .gprc, if for instance mwrank.gp went there.TestingYou are ready to test the installation. Start gp and try some examples:
    ? mwrank([0,-1,1,-10,-20])
    %1 = [[0], []]
    ? mwrank([0,0,1,-1,0])
    %2 = [[1], [[0, 0]]]
    ? mwrank([1,0,0,0,1])
    %3 = [[2], [[1, 1], [3/4, 7/8]]]
 | 
  PARI/GP Development
  
  Last Modified: 2024-10-06 17:08:25
  
  Copyleft © 2003-2025
  the PARI group.