Hi Jean-Louis, Pattern matching is done at compile time, not run-time.
So if you call `lut(2)`, you will get `3` as an output, but if you give
it a variable input like in your example, it will use `lut(n)`. Hope that helps. Feel free to ask for clarification if needed! Cheers,
Bart.

---

On 2022-01-13 15:50, Jean-Louis Paquelin wrote:

Hello there, I can't figure out how the pattern matching works in Faust. I've tried the following code: lut(2) = 3; lut(3) = 4; lut(4) = 2; lut(n) = n; process = hslider("A", 1, 1, 5, 1) : int : lut : hbargraph("B", 1, 5); Trying this in the IDE, the B bargraph simply replicates the A slider value. I was expecting a different behavior thru the lut function: the output of lut should be the same as its input except when the input is 2, 3 or 4, in those cases the output of lut should be 3, 4, 2 respectively. I tried the alternative syntax without any success: lut = case { (2) => 3; (3) => 4; (4) => 2; (n) => n; }; It's as if none of the cases match except the most general one. Did I miss something? I wish you all the best for 2022, health, joy and great projects! Best regards, Jean-Louis _______________________________________________
Faudiostream-users mailing list
Faudiostream-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/faudiostream-users
_______________________________________________
Faudiostream-users mailing list
Faudiostream-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/faudiostream-users

Reply via email to