Can you pairwise multiply using combinators?

Post all other topics which do not belong to any other category.
Post Reply
ribsngibs
Long Handed Inserter
Long Handed Inserter
Posts: 72
Joined: Mon Mar 28, 2016 5:42 am
Contact:

Can you pairwise multiply using combinators?

Post 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?

Frightning
Filter Inserter
Filter Inserter
Posts: 807
Joined: Fri Apr 29, 2016 5:27 pm
Contact:

Re: Can you pairwise multiply using combinators?

Post 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.

kinnom
Filter Inserter
Filter Inserter
Posts: 706
Joined: Fri Dec 26, 2014 4:20 pm
Contact:

Re: Can you pairwise multiply using combinators?

Post 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
no yes yes no yes no yes yes

EvanT
Inserter
Inserter
Posts: 47
Joined: Wed Jul 29, 2015 12:22 pm
Contact:

Re: Can you pairwise multiply using combinators?

Post 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.

ribsngibs
Long Handed Inserter
Long Handed Inserter
Posts: 72
Joined: Mon Mar 28, 2016 5:42 am
Contact:

Re: Can you pairwise multiply using combinators?

Post by ribsngibs »

Thanks for the link to that discussion - there are some combinator masters out there for sure - pretty impressive stuff.

Post Reply

Return to “General discussion”