function definition

Feb 24, 2013 at 1:03 PM

i have defined this function:
f(y) = {
    return y
if i use
return f(1)
then come the error: Variable y has no value defined
can you help me?

Feb 25, 2013 at 1:03 PM
The problem is in the way variable scoping is being handled. The brackets indicate a sub-domain within the global problem domain. At this time, NeturalMath doesn't handle this situation very well--it doesn't pass the parameter of the function call into the same scope as the sub-domain.

Also, the return statement is not needed. NeturalMath is a functional language--each line returns a value, and the value of the last line becomes the returned value of the statement.

The correct syntax you are looking for is:

f(y) = y
Feb 25, 2013 at 2:19 PM
it does not work
Feb 26, 2013 at 12:37 PM
I tested the code using the MathConsole from the /stable/v0.2 directory hosted in Visual Studio 2010. Here is the screenshot of that exercise:

If further support is required, I will need additional information about how you reached the error. The stable branch is the only branch which will be supported, and support will be limited, as this is a pre-alpha stage product, which is no longer under active development.
Feb 26, 2013 at 3:10 PM
Feb 27, 2013 at 2:14 PM
There is insufficient information for me to help you with this issue. More detail, and possibly code samples are required.
Feb 27, 2013 at 2:23 PM
Edited Feb 27, 2013 at 2:23 PM
var runtime = new MathRuntime();

object result = null;
try {
    result = runtime.InterpretText(SyntaxRtb1.Text).Execute().Value;
    ToolStripStatusLabel1.Text = "Result: " + result.ToString();
} catch (MathException ex) {
Feb 27, 2013 at 2:46 PM
As stated earlier in the thread, the ONLY code which will be supported is the /stable/v0.2 branch. The sample code provided uses the MathRuntime class, which is not part of the 0.2 release.

Unfortunately, there are not enough time or resources available to actively maintain NeturalMath. Support can only be provided on a limited basis, and there is no new development being performed at this time.

NeturalMath was created as a syntax-light interpreter for mathematics functions, mainly to assist solving certain physics equations. However, there are already a number of outstanding functional languages which may be used to solve these problems which are far more complete, have third-party support libraries and a large development community. Python and F# immediately come to mind.

If you are still interested in NeturalMath, I would recommend looking into the MathConsole project to understand how commands are input into the system. If you are interested in active development on the NeturalMath project, I would suggest digging around in the code a bit. It is not a particularly complicated system, and I will attempt to explain the purpose of any code which is not well documented, however, I repeat, this project is no longer actively maintained, so support will be limited, and unstable code branches will not be supported at all.