1 | initial version |
The documentation for IntegerListsLex
(accessed for example
using IntegerListsLex?
) does not mention a way to exclude
specific isolated values for the parts.
One way to organise your code would be to give a name to the
properties of A
you want to test for, and write a function
to test them.
For example say we call the function is_palatable
.
Silly example (replace with testing the properties you want):
def is_palatable(A):
return True
Since it is cheap to test whether 7, 11 or 13 are parts of a given integer list, we can write a test for it:
def checks(A):
return 7 not in A and 11 not in A and 13 not in A
and then iterate as follows, starting with the cheap tests before testing the more serious properties if those are likely to take time (this way we only test them if silly checks pass):
I = IntegerListsLex(length=30, min_part=0, max_part=100, min_slope=0)
for A in I:
if checks(A) and is_palatable(A):
print(A)
Another way to write such code is to write an iterator.
it = (A for A in I if checks(A) and is_palatable(A))
Then we can explore these objects one by one:
a = next(it)
print(a)
and explore this object as we need, before getting the next one.