nmodl icon indicating copy to clipboard operation
nmodl copied to clipboard

Review `factorial`.

Open 1uc opened this issue 1 year ago • 1 comments

In nocmodl the string factorial is reserved for the function factorial and will refuse to compile. In NMODL, it seems to generate a user-specified and it doesn't not error out.

Valid:

NEURON {
    SUFFIX recursion
}

FUNCTION myfactorial(n) {
    myfactorial = factorial(n)
} 

Invalid:

NEURON {
    SUFFIX recursion
}

FUNCTION factorial(n) {
    if (n == 0 || n == 1) {
        factorial = 1
    } else {
        factorial = n * factorial(n - 1)
    }
}

1uc avatar Jun 03 '24 13:06 1uc

Yes. factorial is listed in nrn/src/nmodl/extedf.h as a supported function (from the scoop-math library)

nrnhines avatar Jun 03 '24 13:06 nrnhines