Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次の関数 f(x) があります。
f(x) = fun1(x) if x<a f(x) = fun2(x) if a<=x and if x<b f(x) = fun3(x) if b<=x
この関数を文字列に記述して、muparser が理解できるような構文はありますか?
muParser は?:、C/C++ やその他の派生物と同様に、演算子を理解します。したがって、本体は次のように記述できますf(x)。
?:
f(x)
x<a ? fun1(x) : x<b ? fun2(x) : fun3(x)
それが本当にあなたが望むものを捉えているかどうかはわかりませんが、?:短絡しているため機能します(最初の:暗黙的に条件が含まれるように!(x<a))
:
!(x<a)