Message Boards Message Boards

Compute the product between two sets

Posted 9 years ago

Hello,

I'm new with Mathematica, and I search to write an expression that compute the product of two sets.

Table[f[x,y] , {x,S1},{y,S2} ] is nice to write, but as Cross function, it produce 2 parantheses levels rather than one.

{ { f[a,b], f[a,c] } , { f[z,b], f[z,c] } }

I expect to compute { f[a,b], f[a,c], f[z,b], f[z,c] }

Flatten didnt make things better, because f return List object as result.

Sure I dont know how to manipulate data, I really need to progress. Could someone help ?

Kind Regards,

4 Replies

Seems Tuples function provide help, but now, it's not really easy to read :

Table[ f [ x[[1]], x[[2]] ] , {x,Tuples[{S1,S2}]} ]

How could I have the same expression power than before with "local variables" associated to quantifiers/iterators ?

Kind Regards,

POSTED BY: Arnoud Buzing

Perhaps

  Flatten[Outer[f, {a, b}, {c, z}], 1]
POSTED BY: Ilian Gachevski
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract