I am working with python, and I am implementing my code to c# and in python there is method "product", anyone knows if there is something similar in c#? if not maybe someone can put me on a track of how to write this function by myself?
example of product:
a=[[[(1, 2), (3, 4)], [(5, 6), (7, 8)], [(9, 10), (11, 12)]], [[(13, 14), (15, 16)]]]
b= product(*a)
output:
([(1, 2), (3, 4)], [(13, 14), (15, 16)])
([(5, 6), (7, 8)], [(13, 14), (15, 16)])
([(9, 10), (11, 12)], [(13, 14), (15, 16)])
Here is syntax for writing function in c#:
Link:
http://www.dotnetspider.com/forum/139241-How-write-function-c-.net.aspx
Can get information about all kinds of functions in c# on this link.
Assuming you mean itertools.product (it looks like it from the example given):
n.b.
struct
here means thatT
must be a value type or a structure. Change it toclass
if you need to throw in objects such asList
s, but be aware of potential referencing issues.Then as a driver:
Output:
For a product function valid over number of lists, you can use my
CrossProductFunction.CrossProduct
code here:Currently, it doesn't accept
repeat
argument likeitertools.product
does, but it is otherwise similar in functionality and design.