|
|
Is there a way to use an conditional expression in function?
For example, how can I write something like that (the code isn't compilable):
#local =
function(a) {
#if (a < .1)
1
#else
0
#end
}
The compiler says that it doesn't know anything about "a".
Ok, the "#if" condition is calculated only once, but function will be calculated
many times. I try to rewrite the function:
#local =
function(a) {
(a < .1) ? 1 : 0
}
But the compiler says that "Expected 'operator', ? found instead". But as I know
the question sign is a float operator.
Where I'm wrong? And how to write for example step functions? Shall I use the
"select" function?
Unfortunatly I can't see a good way for modelling function like this:
___----_-__- with the "select" function.
Post a reply to this message
|
|