Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function

2020-05-23 Thread Dario Sanfilippo
Hi, Oleg. On Sat, 23 May 2020 at 18:45, Oleg Nesterov wrote: > Dario, > > I'm afraid I can't help. Firstly, I do not really understand your > questions. > But even if I understood, I am not sure I could answer authoritatively. > No worries, I'm sure that it's just my lack of understanding

Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function

2020-05-23 Thread Julius Smith
This thread reminds me of what I found hardest about the Lisp language. How many evals? how many quotes? I remember a lot of trial and error... Regarding > L1 = 1,2,3; > L2 = (1,2,3); > process = ba.count(L1), ba.count((L1)), ba.count(L2), ba.count((L2)); I think 3, 1, 1, 1 would be the

Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function

2020-05-23 Thread Oleg Nesterov
Dario, I'm afraid I can't help. Firstly, I do not really understand your questions. But even if I understood, I am not sure I could answer authoritatively. On 05/22, Dario Sanfilippo wrote: > > On Fri, 22 May 2020 at 20:22, Oleg Nesterov wrote: > > > On 05/22, Dario Sanfilippo wrote: > > > > >

Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function

2020-05-22 Thread Dario Sanfilippo
On Fri, 22 May 2020 at 20:22, Oleg Nesterov wrote: > On 05/22, Dario Sanfilippo wrote: > > > > Sorry for the confusion. What I wanted to ask is: why aren't the extra > > parentheses making a difference? Because (0, (1,2,3)) is parsed as > > ((0),((1,2,3)), right? I missed a parenthesis, I

Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function

2020-05-22 Thread Oleg Nesterov
argh, forgot to comment this part of your email... On 05/22, Dario Sanfilippo wrote: > > On Fri, 22 May 2020 at 08:20, Oleg Nesterov wrote: > > > See above. try > > > > process(3, (_<-100,-1,-1,-1, _==0,0,0,0, _>100,1,1,1, 10,10,10)); > > > > But note that it has 9 inputs, probably not

Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function

2020-05-22 Thread Oleg Nesterov
On 05/22, Dario Sanfilippo wrote: > > Sorry for the confusion. What I wanted to ask is: why aren't the extra > parentheses making a difference? Because (0, (1,2,3)) is parsed as > ((0),((1,2,3)), right? Sorry, can't understand... but in any case, I think that extra parentheses should _only_ make

Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function

2020-05-22 Thread Dario Sanfilippo
Sorry for the confusion. What I wanted to ask is: why aren't the extra parentheses making a difference? Because (0, (1,2,3)) is parsed as ((0),((1,2,3)), right? I guess that what you explained earlier is also why process = ba.count(((1,2),(3,4))); results in 3 instead of 2. Dario On Fri, 22 May

Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function

2020-05-22 Thread Oleg Nesterov
On 05/22, Dario Sanfilippo wrote: > > > But this doesn't really matter. What (I think) does matter is that, say, > > 1,2 should match (x,xs), no matter how many parentheses you add. > > > > What is the reason why this is not happening? confused... this _is_ happening, iiuc. And again,

Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function

2020-05-22 Thread Dario Sanfilippo
On Fri, 22 May 2020 at 08:20, Oleg Nesterov wrote: > On 05/22, Dario Sanfilippo wrote: > > > > > As for ifN. Perhaps something like this can work for you: > > > > > > ifN(N, inp) = par(n, N, line(n,C)) with { > > > C = (outputs(inp) - N) / (N + 1); > > >

Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function

2020-05-22 Thread Alejandro Olarte
Thank you. > On 22 May 2020, at 12.10, Stéphane Letz wrote: > > > https://join.slack.com/t/faustaudio/shared_invite/zt-a624szlz-fL4v2DTR~ZGlI7wARryT7g > > >> Le 22 mai 2020 à 09:20, Alejandro Olarte a écrit : >> >> Could somebody point me to the Slack channel? I like to follow it. >>

Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function

2020-05-22 Thread Stéphane Letz
https://join.slack.com/t/faustaudio/shared_invite/zt-a624szlz-fL4v2DTR~ZGlI7wARryT7g > Le 22 mai 2020 à 09:20, Alejandro Olarte a écrit : > > Could somebody point me to the Slack channel? I like to follow it. > Thanks, > Alejandro > >> On 22 May 2020, at 10.10, Stéphane Letz wrote: >> >>

Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function

2020-05-22 Thread Alejandro Olarte
Could somebody point me to the Slack channel? I like to follow it. Thanks, Alejandro > On 22 May 2020, at 10.10, Stéphane Letz wrote: > > Faust Slack or Discord channels allows faster interactions which helps debug > sometimes... > > We have the mailing list, those 2 channels and the >

Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function

2020-05-22 Thread Stéphane Letz
Faust Slack or Discord channels allows faster interactions which helps debug sometimes... We have the mailing list, those 2 channels and the https://github.com/grame-cncm/faust/issues We could even add a forum ? I try to follow everything... Stéphane > Personally, regardless of the

Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function

2020-05-22 Thread Oleg Nesterov
On 05/22, Dario Sanfilippo wrote: > > > As for ifN. Perhaps something like this can work for you: > > > > ifN(N, inp) = par(n, N, line(n,C)) with { > > C = (outputs(inp) - N) / (N + 1); > > take(i) = inp : route(outputs(inp),1,i+1,1); > >

Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function

2020-05-21 Thread Stéphane Letz
> > I managed to find a commit talking about the "route" primitive, but I > couldn't find anything about "outputs": what is it? > > If I run > Look at « Inputs and Outputs of an Expression » section in https://faustdoc.grame.fr/manual/syntax/ Stéphane

Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function

2020-05-21 Thread Dario Sanfilippo
Hello! On Thu, 21 May 2020 at 17:33, Oleg Nesterov wrote: > On 05/20, Dario Sanfilippo wrote: > > > > I use the "ceil" function for the cond in "if" as I want _any_ non-zero > > value to result true, whereas ba.if gives false for any fractional > > condition < 1. I opened an issue about this

Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function

2020-05-21 Thread Oleg Nesterov
On 05/20, Dario Sanfilippo wrote: > > I use the "ceil" function for the cond in "if" as I want _any_ non-zero > value to result true, whereas ba.if gives false for any fractional > condition < 1. I opened an issue about this but I think that fixing it, if > bad behaviour (bad if thinking of C/C++,

Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function

2020-05-20 Thread Dario Sanfilippo
Sorry for replying off-list earlier, Oleg. You're right that it could be useful for others too. I see why the function that we discussed wouldn't work to output sets of values for each condition. (The others reading, see below.) I use the "ceil" function for the cond in "if" as I want _any_

Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function

2020-05-20 Thread Oleg Nesterov
On 05/20, Dario Sanfilippo wrote: > > a_f(f) = ifthenelseif(( f < 25, .532, > f < 31.5, .506, > f < 40, .480, > f < 50, .455, > f < 63, .432, > f < 80, .409, > f < 100, .387, > f < 125, .367, > f < 160, .349, > f < 200, .330, > f < 250, .315, > f < 315, .301, > f < 400, .288, > f < 500, .286, > f

Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function

2020-05-20 Thread Dario Sanfilippo
I thought that it would be useful for something like what you see below. Those are some of the frequency-dependent coefficients of the ISO226 equal-loudness curves, but really I mostly wanted to better understand pattern matching. Cheers, Dario import("stdfaust.lib"); ifthenelse(cond,then,else)

Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function

2020-05-20 Thread Oleg Nesterov
On 05/20, Dario Sanfilippo wrote: > > Was there already something like that not that I'm aware of, > or was there a simpler way of doing > it? Sorry, I don't understand... doing what?? why do you want this helper? Oleg. ___ Faudiostream-users

Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function

2020-05-20 Thread Dario Sanfilippo
Oleg nailing it again. That's what I was looking for. Thanks :-) It is just an if-then-else-if function, with an arbitrary number of ifs. Was there already something like that or was there a simpler way of doing it? Dario On Wed, 20 May 2020 at 12:11, Oleg Nesterov wrote: > On 05/19, Dario

Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function

2020-05-20 Thread Oleg Nesterov
On 05/19, Dario Sanfilippo wrote: > > Hello, list. I hope that you're all well. > > I just started using pattern matching and I'd kindly ask for your help to > better understand how things work. > > The goal is to implement an *ifthenelseif* function that takes cond-then > pairs as arguments