Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function
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 making my questions twisted. I appreciate your time answering me. > > On 05/22, Dario Sanfilippo wrote: > > > > 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 meant that (0, (1,2,3)) is parsed as ((0), > > ((1,2,3))) > > Why do you think so? If I'm not wrong, a similar behaviour was decribed by Julius in his section on *count* and *take*: https://ccrma.stanford.edu/~jos/aspf/Understanding_count_take_math_lib.html. > OK, please consider > > f(((x,y))) = x+y; > f( (x,y) ) = x-y; > > process(x,y) = f((x,y)); > > note the compiler warning: > > WARNING : shadowed pattern-matching rule: (,) => x,y : -; > previous rule was: (,) => x,y : +; > > See? The extra parentheses make no difference. > And why do you think they should? IMO, this would be insane. Suppose you > change the compiler so that ba.count(((1,2,3))) returns 1. Now, what should > this program > > L1 = 1,2,3; > L2 = (1,2,3); > > process = ba.count(L1), ba.count((L1)), > ba.count(L2), ba.count((L2)); > > output? > I would have guessed that ba.count(L1) would have triggered an error, as ba.count(1,2,3) does. Then I would have guessed 3 3 1 for the others. > > Or this one > > process = ba.count(par(i,3,i)), ba.count((par(i,3,i))); > > ? > Error and 3. > > The current rules are at least clear/understandable, and whatever you or > me think it is too late to change them. > Yes, I understand that. If we could have more documentation on the eval rules as Julius suggests that would be great. Thanks again to all of you for your time. Dario ___ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users
Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function
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 best answer, and 3, 1, 3, 1 second best, although I know it is now 3, 3, 3, 3. In any case, all implicit eval rules should be clearly predictable and documented. Cheers, - Julius On Sat, May 23, 2020 at 9:46 AM 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. > > On 05/22, Dario Sanfilippo wrote: > > > > 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 meant that (0, (1,2,3)) is parsed as ((0), > > ((1,2,3))) > > Why do you think so? OK, please consider > > f(((x,y))) = x+y; > f( (x,y) ) = x-y; > > process(x,y) = f((x,y)); > > note the compiler warning: > > WARNING : shadowed pattern-matching rule: (,) => x,y : -; > previous rule was: (,) => x,y : +; > > See? The extra parentheses make no difference. > > And why do you think they should? IMO, this would be insane. Suppose you > change the compiler so that ba.count(((1,2,3))) returns 1. Now, what should > this program > > L1 = 1,2,3; > L2 = (1,2,3); > > process = ba.count(L1), ba.count((L1)), > ba.count(L2), ba.count((L2)); > > output? > > Or this one > > process = ba.count(par(i,3,i)), ba.count((par(i,3,i))); > > ? > > The current rules are at least clear/understandable, and whatever you or > me think it is too late to change them. > > Oleg. > > > > ___ > Faudiostream-users mailing list > Faudiostream-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/faudiostream-users > -- "Anybody who knows all about nothing knows everything" -- Leonard Susskind ___ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users
Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function
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: > > > > > > 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 meant that (0, (1,2,3)) is parsed as ((0), > ((1,2,3))) Why do you think so? OK, please consider f(((x,y))) = x+y; f( (x,y) ) = x-y; process(x,y) = f((x,y)); note the compiler warning: WARNING : shadowed pattern-matching rule: (,) => x,y : -; previous rule was: (,) => x,y : +; See? The extra parentheses make no difference. And why do you think they should? IMO, this would be insane. Suppose you change the compiler so that ba.count(((1,2,3))) returns 1. Now, what should this program L1 = 1,2,3; L2 = (1,2,3); process = ba.count(L1), ba.count((L1)), ba.count(L2), ba.count((L2)); output? Or this one process = ba.count(par(i,3,i)), ba.count((par(i,3,i))); ? The current rules are at least clear/understandable, and whatever you or me think it is too late to change them. Oleg. ___ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users
Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function
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 meant that (0, (1,2,3)) is parsed as ((0), ((1,2,3))) > Sorry, can't understand... > > but in any case, I think that extra parentheses should _only_ make > a difference when expr is "list", say, "1,2,3". > But that's always the case with take and count, isn't it? > > and in any case, I do not think that "(1,2,3)" is parsed as "((1,2,3))". > If I'm not wrong, it is parsed as ((1), (2,3)). So if we had (0, (1,2,3)) parsed as ((0), ((1,2,3))), we'd end up with take(1, ((1,2,3))), right? So in that case I thought that parentheses could make the difference. Dario ___ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users
Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function
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 what you want. Use "_ <: > > ifN(...)" > > or "_,_,_ <: ifN(...)" depending on what do you need. > > > > I'm actually seeing 3*3*7 inputs. Yes, thanks for correcting me. 3*3*7 inputs, 3*3 is used. Oleg. ___ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users
Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function
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 a difference when expr is "list", say, "1,2,3". and in any case, I do not think that "(1,2,3)" is parsed as "((1,2,3))". However I think that "((1,2,3))" and "(1,2,3)" should be the same thing. > I guess that what you explained earlier is also why process = > ba.count(((1,2),(3,4))); results in 3 instead of 2. Yes. Oleg. ___ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users
Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function
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 2020 at 19:31, Oleg Nesterov wrote: > 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, IIUC that is why > "take(2, (0, (1,2,3)))" doesn't return (1,2,3) as you want; after the > 1st step it leads to take(1, (1,2,3)) and "(1,2,3)" matches "(xs,xxs)"). > > > As a workaround, could it be possible to rewrite take so that a dummy > > element is attached at the end of the list? I'll try. > > Good luck ;) I don't think this is possible. > > Oleg. > > ___ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users
Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function
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, IIUC that is why "take(2, (0, (1,2,3)))" doesn't return (1,2,3) as you want; after the 1st step it leads to take(1, (1,2,3)) and "(1,2,3)" matches "(xs,xxs)"). > As a workaround, could it be possible to rewrite take so that a dummy > element is attached at the end of the list? I'll try. Good luck ;) I don't think this is possible. Oleg. ___ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users
Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function
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); > > > take(i) = inp : route(outputs(inp),1,i+1,1); > > > cond(c) = take((N+1) * c) != 0; > > > else(n) = take((N+1) * C + n); > > > then(n,c) = take((N+1) * c + n + 1); > > > > > > line(n,0) = else(n); > > > line(n,c) = select2(cond(C-c), line(n,c-1), > then(n,C-c)); > > > }; > > > > > > the 1st arg N is the number of outputs. Example: > > > > > > prtcess = ifN(3, C1,t11,t12,t13, C2,t21,t22,t23, ..., > > > Cn,tn1,tn2,tn3, e1,e2,e3). > > Sorry, I meant > > process = ifN(3, (C1,t11,t12,t13, C2,t21,t22,t23, ..., > Cn,tn1,tn2,tn3, e1,e2,e3)); > > the 2nd arg is list. > Cool, thanks. > > > If I run > > > > process = ifN(3, _<-100,-1,-1,-1, _==0,0,0,0, _>100,1,1,1, 10,10,10); > > > > I get ERROR : stack overflow in eval. > > 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 what you want. Use "_ <: > ifN(...)" > or "_,_,_ <: ifN(...)" depending on what do you need. > I'm actually seeing 3*3*7 inputs. > > > Going a bit back: you said that Faust doesn't distinguish between (1,2,3) > > and ((1,2,3)) and that it obviously makes sense; could you elaborate why? > > Well, to me "expr", "(expr)", "(expre)" should be the same thing. > Unless "expr" is the list of expressions, so "1,2" and "(1,2)" is obviously > not the same thing. > > 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? As a workaround, could it be possible to rewrite take so that a dummy element is attached at the end of the list? I'll try. > > > Personally, regardless of the complexity of the issue, I'd love to see > > emails here on the list on a daily basis. > > Me too! > > > Here is the link: > > https://discord.com/channels/382895736356077570/651037481017409595. > > thanks... Needs registration. Not for me. > (Damn yes, I joined faustaudio and I am ashamed I did this, but this is > because I like faust too much ;) > I still hope we'll hear from you there too sometimes! Ciao :) ___ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users
Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function
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. >> 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 >>> https://github.com/grame-cncm/faust/issues >>> >>> We could even add a forum ? >>> >>> I try to follow everything... >>> >>> Stéphane >>> >>> Personally, regardless of the complexity of the issue, I'd love to see emails here on the list on a daily basis. >>> >>> >>> >>> ___ >>> 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
Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function
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: >> >> 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 complexity of the issue, I'd love to see >>> emails here on the list on a daily basis. >>> >> >> >> >> ___ >> 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
Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function
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 > https://github.com/grame-cncm/faust/issues > > We could even add a forum ? > > I try to follow everything... > > Stéphane > > >> Personally, regardless of the complexity of the issue, I'd love to see >> emails here on the list on a daily basis. >> > > > > ___ > 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
Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function
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 complexity of the issue, I'd love to see > emails here on the list on a daily basis. > ___ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users
Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function
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); > > cond(c) = take((N+1) * c) != 0; > > else(n) = take((N+1) * C + n); > > then(n,c) = take((N+1) * c + n + 1); > > > > line(n,0) = else(n); > > line(n,c) = select2(cond(C-c), line(n,c-1), then(n,C-c)); > > }; > > > > the 1st arg N is the number of outputs. Example: > > > > prtcess = ifN(3, C1,t11,t12,t13, C2,t21,t22,t23, ..., > > Cn,tn1,tn2,tn3, e1,e2,e3). Sorry, I meant process = ifN(3, (C1,t11,t12,t13, C2,t21,t22,t23, ..., Cn,tn1,tn2,tn3, e1,e2,e3)); the 2nd arg is list. > If I run > > process = ifN(3, _<-100,-1,-1,-1, _==0,0,0,0, _>100,1,1,1, 10,10,10); > > I get ERROR : stack overflow in eval. 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 what you want. Use "_ <: ifN(...)" or "_,_,_ <: ifN(...)" depending on what do you need. > Going a bit back: you said that Faust doesn't distinguish between (1,2,3) > and ((1,2,3)) and that it obviously makes sense; could you elaborate why? Well, to me "expr", "(expr)", "(expre)" should be the same thing. Unless "expr" is the list of expressions, so "1,2" and "(1,2)" is obviously not the same thing. 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. > Personally, regardless of the complexity of the issue, I'd love to see > emails here on the list on a daily basis. Me too! > Here is the link: > https://discord.com/channels/382895736356077570/651037481017409595. thanks... Needs registration. Not for me. (Damn yes, I joined faustaudio and I am ashamed I did this, but this is because I like faust too much ;) Oleg. ___ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users
Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function
> > 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 ___ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users
Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function
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 but I think that fixing it, > if > > bad behaviour (bad if thinking of C/C++, maybe), may break other code. > > Heh, I didn't even know that select2 typecasts the 1st input to "int" ;) > Thanks. But then I think !=(0) makes more sense than ceil... > Sure, that's formally more correct. > > 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); > cond(c) = take((N+1) * c) != 0; > else(n) = take((N+1) * C + n); > then(n,c) = take((N+1) * c + n + 1); > > line(n,0) = else(n); > line(n,c) = select2(cond(C-c), line(n,c-1), then(n,C-c)); > }; > > the 1st arg N is the number of outputs. Example: > > prtcess = ifN(3, C1,t11,t12,t13, C2,t21,t22,t23, ..., > Cn,tn1,tn2,tn3, e1,e2,e3). > > I wrote this without any thinking, there must be a more elegant solution. > 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 process = ifN(3, _<-100,-1,-1,-1, _==0,0,0,0, _>100,1,1,1, 10,10,10); I get ERROR : stack overflow in eval. Going a bit back: you said that Faust doesn't distinguish between (1,2,3) and ((1,2,3)) and that it obviously makes sense; could you elaborate why? > > > The Slack and Discord Faust channels may be drawing attention away from > the > > list. Perhaps we can suggest people to also post on the list besides the > > channels when there's an issue. > > Cough, can't resist... I hate the very idea of Slack ;) > Heh, I understand. I think that the discussions on Slack are more about less advanced topics and new users feel less pressure asking there rather than on the list. Personally, regardless of the complexity of the issue, I'd love to see emails here on the list on a daily basis. > > I have already found faustaudio.slack.com (after you mentioned it some > time > ago), but what is Discord channel? google didn't help... > I'm not familiar with it. Stéphane just pointed out that the "the audio programmer" Discord server has rooms for both Faust and Juce, as I was asking about something related to the two. Here is the link: https://discord.com/channels/382895736356077570/651037481017409595. As always, thanks a lot for your time. :-) Dario ___ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users
Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function
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++, maybe), may break other code. Heh, I didn't even know that select2 typecasts the 1st input to "int" ;) Thanks. But then I think !=(0) makes more sense than ceil... 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); cond(c) = take((N+1) * c) != 0; else(n) = take((N+1) * C + n); then(n,c) = take((N+1) * c + n + 1); line(n,0) = else(n); line(n,c) = select2(cond(C-c), line(n,c-1), then(n,C-c)); }; the 1st arg N is the number of outputs. Example: prtcess = ifN(3, C1,t11,t12,t13, C2,t21,t22,t23, ..., Cn,tn1,tn2,tn3, e1,e2,e3). I wrote this without any thinking, there must be a more elegant solution. > The Slack and Discord Faust channels may be drawing attention away from the > list. Perhaps we can suggest people to also post on the list besides the > channels when there's an issue. Cough, can't resist... I hate the very idea of Slack ;) I have already found faustaudio.slack.com (after you mentioned it some time ago), but what is Discord channel? google didn't help... Oleg. ___ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users
Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function
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_ 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++, maybe), may break other code. The Slack and Discord Faust channels may be drawing attention away from the list. Perhaps we can suggest people to also post on the list besides the channels when there's an issue. Thanks again for your help, Dario On Wed, 20 May 2020 at 19:39, Oleg Nesterov wrote: > Hi Dario, > > Why offlist?? > > this discussion can be useful for someone else, plus other people could > help you. Not to mention this list is already almost dead, as if faust > has no users. > > On 05/20, Dario Sanfilippo wrote: > > Thanks, Oleg. > > > > I'm noticing that the function wouldn't work if we wanted to output a set > > of values for each condition instead of just one. > > Yes, this won't work. Faust's "lists" are very limited. > > I think the key problem is that faust discriminates ((a,b), (c,d)) > from (a,b,c,d), but ((a,b)) is always the same as (a,b) and the latter > obviously makes sense. > > that is why take(2, (whatever, (7,8,9))) doesn't work as you want, it > leads to take(1, ((7,8,9))) and this is the same as take(1, 7,8,9). > > Same for ifN below. > > In any case, > > > ifN((c, t, e)) = if(c, t, ifN(e)); > > ifN(e) = e; > > if(cond, then, else) = ceil(cond) , > > else , > > then : select2; > > I don't understand why do you complicate this and put "ceil" into the > new generic helper. > > Oleg. > > ___ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users
Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function
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 < 630, .267, > f < 800, .259, > f < 1000, .253, > .250)); for this particular case you can look at ba.bpf(). Note that it interpolates the values in between, I do not know if you want this or not. Oleg. ___ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users
Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function
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) = ceil(cond) , else , then : select2; ifthenelseif((c, t, e)) = ifthenelse(c, t, ifthenelseif(e)); ifthenelseif(e) = e; 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 < 630, .267, f < 800, .259, f < 1000, .253, .250)); process = a_f(hslider("f", 0, 0, 1000, 1)); On Wed, 20 May 2020 at 15:08, Oleg Nesterov wrote: > 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 mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users
Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function
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 mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users
Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function
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 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 except the last set of arguments that are > > cond-then-else. The function should look like this, > > > > ifthenelseif(C1, T1, C2, T2, Cn, Tn, E); > > > > and unfold into this, > > > > if(C1, T1, if(C2, T2, if(Cn, Tn, E))); . > > Not sure I understand what exactly do you want... but you can pass a single > list. Say, > > ifthenelse((c, t, e)) = select2(c, ifthenelse(e), t); > ifthenelse(e) = e; > > process = ifthenelse((C1,T1, C2,T2, ..., Cn,Tn, E)); > > Oleg. > > ___ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users
Re: [Faudiostream-users] Help with pattern matching to implement an if-then-else-if function
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 except the last set of arguments that are > cond-then-else. The function should look like this, > > ifthenelseif(C1, T1, C2, T2, Cn, Tn, E); > > and unfold into this, > > if(C1, T1, if(C2, T2, if(Cn, Tn, E))); . Not sure I understand what exactly do you want... but you can pass a single list. Say, ifthenelse((c, t, e)) = select2(c, ifthenelse(e), t); ifthenelse(e) = e; process = ifthenelse((C1,T1, C2,T2, ..., Cn,Tn, E)); Oleg. ___ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users