# Function output

I would like a function that computes Cartesian product of two sets z=(Tuples@{#1,#2}), and computes the number of elements in this set(list) Length@z which have a x elements in #1 and y elements in #2 (ie x y == numbers of elements in z).

As function output I want to receive a list that has as first of last element x*y and the next\previous "element" as z.

{{x*y}, z} or {z,{x*y}}


And does it exist a way to produce "multi-data out" like

in[a]=foofunction
out[a] = foo1
out[a+1] = foo2


Generally, what I should use if I would like to see intermediate calculations (and don't see another), if I don't want use Length[%] on function result and don't want have it in function result (as in question one). Something like:

    in[a]=foofunction
output1=.. //intermediate calculations (for example Length[z] in quest.1)
output2=... //intermediate calculations
output[a]= ... //result


Obviously, I tried to use Print, and Join within Module, Something like

 Module[{},
c = {};
a = Tuples@{#1, #2} &;
c=Length@a~Join~c;
Print@c
]


It doesn't work, but I think it could provide some information about what I want. I would be grateful for any information, maybe some articles I've missed.

• Can you give us a sample input and output? That will help, as I can't quite understand what you want from your write-up, although I have an idea. – march Mar 11 '16 at 16:44
• Ok, let's try begin with small pieces. x = {1,2,3}; y={5,6,7} ; z=Tuples[{x,y}] output = {Lenght[z], z } <- (variant 1) , (variant 2) -> output = {z} , output2= Lenght[z] (in this variant output2 works like side effect of calculations). Generally speaking, in my mind twisting question how to write complicated funct in single piece of text, like main function in C, carrying some operation hiden, some has printed but just like slide-effect. – Gelios Mar 11 '16 at 18:39