January 2nd, 2020

evilphish
  • shlomif

Tech Tip: Implementing assert() in PARI/GP

One can implement assert() in PARI-GP, a GPLed computer algebra system, using the error() function:

assert(cond,err)=if(!cond,error(err))
myfunc()=4
assert(myfunc()==5,"myfunc should return 5")

Licence

Copyright by Shlomi Fish, 2020.

You can reuse this entry under the Creative Commons Attribution 4.0 Unported licence, or at your option any later version of it. See the instructions on how to comply with it.

Whatever code given here is provided under the MIT / Expat licence.

  • Current Music
    George Harrison - I've got my mind set on you