Hi Oleg,

Here is an implementation of apply. It's the closest I've found ;-). The
idea is to pass to the op function a list of selectors that simulate the
formal parameters but that can be created in arbitrary numbers.

tsum((x, xs)) = sin(x)/cos(x) + tsum(xs);
tsum(x) = sin(x)/cos(x);

apply(N,op) = par(i,N,_) <: op(selectors(N))
with {
selectors(N) = par(i,N,selector(N,i));
selector(N,i) = route(N,1,i+1,1);
};

//process = \(x1,x2,x3,x4).(tsum((x1,x2,x3,x4)));
process = apply(4,tsum);


Cheers

Yann

*Yann Orlarey*
Directeur scientifique/Scientific director


orla...@grame.fr <x...@grame.fr> T : +33 (0) 4 72 07 37 00
GRAME - Centre national de création musicale
11 cours de Verdun Gensoul | 69002 Lyon
www.grame.fr | facebook <https://www.facebook.com/Gramelyon/> | instagram
<https://www.instagram.com/grame_cncm/> | twitter
<https://twitter.com/GRAME_LYON>


Le sam. 18 juil. 2020 à 11:28, Oleg Nesterov <o...@redhat.com> a écrit :

> Hi Yann,
>
> On 07/17, Yann Orlarey wrote:
> >
> > I'm not sure that answers your question,
>
> No it doesn't ;) probably I wasn't clear, please see below.
>
> > but you can do that, for instance:
>
> of course, you can always rewrite dsBus2int or anything else, but what
> if you do not want to change the "wants-the-list" function?
>
> Let me provide a stupid/artificial but simple example. Suppose you have
>
>         tsum((x, xs)) = tan(x) + tsum(xs);
>         tsum(x) = tan(x);
>
> Now,
>         process = si.bus(4) : tsum;
>
> obviously won't work.
>
>         process = tsum(si.bus(4));
>
> works, but only because "tsum" is simple enough. Lets complicate it:
>
>         tsum((x, xs)) = sin(x)/cos(x) + tsum(xs);
>         tsum(x) = sin(x)/cos(x);
>
> after this change
>
>         process = tsum(si.bus(4));
>
> no longer works as expected, it has 4*2 inputs. You have to do
>
>         process(x1,x2,x3,x4) = tsum((x1,x2,x3,x4));
> or
>         process = \(x1,x2,x3,x4).(tsum((x1,x2,x3,x4)));
>
> but this is very inconvenient and doesn't allow to specify the number
> of inputs.
>
> The best solution I was able to find is something like this:
>
>         apply(1, op) = \(x1).                   (op((x1)));
>         apply(2, op) = \(x1,x2).                (op((x1,x2)));
>         apply(3, op) = \(x1,x2,x3).             (op((x1,x2,x3)));
>         apply(4, op) = \(x1,x2,x3,x4).          (op((x1,x2,x3,x4)));
>         apply(5, op) = \(x1,x2,x3,x4,x5).       (op((x1,x2,x3,x4,x5)));
>         ...
>         apply(32,op) = ...;
>
> this allows to do
>
>         process = apply(N, tsum);
>
> as long as N is constant and <= 32. But this is not nice, and I do not
> know how can I define apply(n, op) for any "n".
>
> Oleg.
>
>
_______________________________________________
Faudiostream-users mailing list
Faudiostream-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/faudiostream-users

Reply via email to