MCPcopy Create free account
hub / github.com/Singular/Singular / rloop

Function rloop

Singular/dyn_modules/python/cart.py:8–17  ·  view source on GitHub ↗

recursive looping function

(seqin,comb)

Source from the content-addressed store, hash-verified

6StopIteration exception. This will not create the whole list of
7combinations in memory at once.'''
8 def rloop(seqin,comb):
9 '''recursive looping function'''
10 if seqin: # any more sequences to process?
11 for item in seqin[0]:
12 newcomb=comb+[item] # add next item to current combination
13 # call rloop w/ remaining seqs, newcomb
14 for item in rloop(seqin[1:],newcomb):
15 yield item # seqs and newcomb
16 else: # processing last sequence
17 yield comb # comb finished, add to list
18 return rloop(seqin,[])
19
20def cartn(sequence, n):

Callers 1

xcombineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected