Dear Richard,
You can do:
#+BEGIN_SRC mathematicaf[x_] := x+3;f[5]#+END_SRCHere are explanations: I actually put everything in the SRC block into a Print[...].
So in the second example, what actually runs is
Print[f[x_] := x+3
f[5]]
This does not return any value. Because what it really does is print the value of "f[x_] := x+3 f[5]"
Here is the code:
(concat
(mapconcat ;; define any variables
(lambda (pair)
(format "%s=%s;"
(car pair)
(org-babel-mathematica-var-to-mathematica (cdr pair))))
vars "\n") "\nPrint[\n" body "\n]\n")
If anybody has idea to improve it, I will be happy to see and work it out!
Best,
Yi