Nim bindings for working with Mathematica or the Wolfram language.
There is mainly two wrapper method for easy usage:
launch
can be used to launch a standalone Mathematica/Wolfram kernel in the background
and communicate with the WSTP
protocol as followos
import wstp/launch
let lp = launch()
lp.PutFunction("EvaluatePacket", 1)
lp.PutFunction("DateString", 0)
lp.EndPacket()
lp.waitReturn()
var s: cstring
lp.GetString(s.addr)
echo "result: ", s
lp.ReleaseString(s)
run
applications tipically would be used to add functionalities to Mathematica/Wolfram by
using Install[path/to/executable]
to be started as an subprocess of Mathematcia
.
One example is as follows:
static:
discard staticExec("wsprep -o addtwo.tm.c addtwo.tm")
{.compile:"addtwo.tm.c".}
import wstp/run
proc addtwo(i,j:int): int {.exportc.} =
return i+j
run()
remeber this still requires addtwo.tm
.