No description
Find a file
2019-09-29 00:58:44 +08:00
headers add new defs 2019-09-26 00:52:25 +08:00
src add auto eval support 2019-09-29 00:58:44 +08:00
tests add example: dateString.nim 2018-08-06 19:11:53 +08:00
.gitignore add example: dateString.nim 2018-08-06 19:11:53 +08:00
ReadMe.md add readme 2018-08-14 13:08:16 +08:00
wstp.nimble using runWSTP and launchLink sep the diffreent runnming mode for MMA 2018-08-04 23:02:24 +08:00

Nim bindings for WSTP

Nim bindings for working with Mathematica or the Wolfram language.

There is mainly two wrapper method for easy usage:

launch

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

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.

see also

Matlab/Simulink nim-mex

Are we scientists yet?