BlueBrain / nmodl

Code Generation Framework For NEURON MODeling Language
https://bluebrain.github.io/nmodl/
Apache License 2.0
48 stars 15 forks source link

Review `factorial`. #1292

Open 1uc opened 1 month ago

1uc commented 1 month ago

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)
    }
}
nrnhines commented 1 month ago

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