Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

mathematica

By: a guest on Apr 23rd, 2012  |  syntax: None  |  size: 0.73 KB  |  views: 56  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. >>> from mathlink import *
  2. >>> import exceptions,sys, re, os
  3. >>> from types import ListType
  4. >>> mathematicaversion = "8.0"
  5. >>> os.environ["PATH"] = "/usr/local/Wolfram/Mathematica/" + mathematicaversion + ":/usr/local/bin:/usr/bin:/bin"
  6. >>> e = env()
  7. >>> sys.argv=['textfrontend.py', '-linkname', 'math -mathlink', '-linkmode', 'launch']
  8. >>> kernel = e.openargv(sys.argv)
  9. >>> kernel.connect()
  10. >>> kernel.ready()
  11. 0
  12. >>> kernel.putfunction("Prime",1)
  13. >>> kernel.putinteger(10)
  14. >>> kernel.flush()
  15. >>> kernel.ready()
  16. 0
  17. >>> kernel.nextpacket()
  18. 8
  19. >>> packetdescriptiondictionary[3]
  20. 'ReturnPacket'
  21. >>> kernel.getinteger()
  22. Traceback (most recent call last):
  23.   File "<stdin>", line 1, in <module>
  24. mathlink.error: MLGet out of sequence.