Page 1 of 1

Can you pairwise multiply using combinators?

Posted: Sat Sep 03, 2016 5:15 pm
by ribsngibs
Just getting around to exploring what's possible with combinators in .13, and the *each* special signal is pretty awesome. It's allowing me to do all sorts of fun things by sending a whole bunch of signals at once and do operations on them - useful for sending inventory requests, for example.

One thing I'd like to do that I haven't figured out is do a pairwise multiply without just using a combinator per signal. Is this possible?

e.g. if I have one network that has these signals "red 1 green 3 blue 12" and another that looks like "red 2 green 2 blue 3" I'd like to be able to use a constant number of combinators (so, doesn't scale up with the number of signals) and get "red 2 green 6 blue 36".

Is this possible?

Re: Can you pairwise multiply using combinators?

Posted: Sat Sep 03, 2016 5:51 pm
by Frightning
ribsngibs wrote:Just getting around to exploring what's possible with combinators in .13, and the *each* special signal is pretty awesome. It's allowing me to do all sorts of fun things by sending a whole bunch of signals at once and do operations on them - useful for sending inventory requests, for example.

One thing I'd like to do that I haven't figured out is do a pairwise multiply without just using a combinator per signal. Is this possible?

e.g. if I have one network that has these signals "red 1 green 3 blue 12" and another that looks like "red 2 green 2 blue 3" I'd like to be able to use a constant number of combinators (so, doesn't scale up with the number of signals) and get "red 2 green 6 blue 36".

Is this possible?
Wouldn't an arithmetic combinator with output set to Each*Each do it? I mean, as long as one of the inputs is the red wire, the other green, I would expect it to do that.

Re: Can you pairwise multiply using combinators?

Posted: Sat Sep 03, 2016 6:46 pm
by kinnom
Frightning wrote:
ribsngibs wrote:Just getting around to exploring what's possible with combinators in .13, and the *each* special signal is pretty awesome. It's allowing me to do all sorts of fun things by sending a whole bunch of signals at once and do operations on them - useful for sending inventory requests, for example.

One thing I'd like to do that I haven't figured out is do a pairwise multiply without just using a combinator per signal. Is this possible?

e.g. if I have one network that has these signals "red 1 green 3 blue 12" and another that looks like "red 2 green 2 blue 3" I'd like to be able to use a constant number of combinators (so, doesn't scale up with the number of signals) and get "red 2 green 6 blue 36".

Is this possible?
Wouldn't an arithmetic combinator with output set to Each*Each do it? I mean, as long as one of the inputs is the red wire, the other green, I would expect it to do that.
no, anything getting a signal from the CN just adds the values of each network together.
also, an arithmatic combinator can't use Each for the second input

Re: Can you pairwise multiply using combinators?

Posted: Sat Sep 03, 2016 11:41 pm
by EvanT
As far as I have read the doku you could make a mod that can perform operations like green wire times red wire since there are methods in place to read the wire signals separate from each other. But I have not found a method to write the result back to the output side.

XKnight posted a vanilla method here but it is complicated since it involves splitting the signals, performing the operation one signal at a time and buffering the individual signals to get a complete result.

Re: Can you pairwise multiply using combinators?

Posted: Sun Sep 04, 2016 5:58 am
by ribsngibs
Thanks for the link to that discussion - there are some combinator masters out there for sure - pretty impressive stuff.