MCPcopy Index your code
hub / github.com/clips/pattern / product

Function product

pattern/text/search.py:124–141  ·  view source on GitHub ↗

Yields all permutations with replacement: list(product("cat", repeat=2)) => [("c", "c"), ("c", "a"), ("c", "t"), ("a", "c"), ("a", "a"), ("a", "t"), ("t", "c"), ("t", "a"), ("t", "t")]

(*args, **kwargs)

Source from the content-addressed store, hash-verified

122 return product(iterable, repeat=n)
123
124def product(*args, **kwargs):
125 """ Yields all permutations with replacement:
126 list(product("cat", repeat=2)) =>
127 [("c", "c"),
128 ("c", "a"),
129 ("c", "t"),
130 ("a", "c"),
131 ("a", "a"),
132 ("a", "t"),
133 ("t", "c"),
134 ("t", "a"),
135 ("t", "t")]
136 """
137 p = [[]]
138 for iterable in map(tuple, args) * kwargs.get("repeat", 1):
139 p = [x + [y] for x in p for y in iterable]
140 for p in p:
141 yield tuple(p)
142
143try: from itertools import product
144except:

Callers 2

combinationsFunction · 0.70
variationsFunction · 0.70

Calls 1

getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…