[seqfan] about self-contained python code

M. F. Hasler oeis at hasler.fr
Thu Feb 23 20:47:39 CET 2023

Recently a contribution of mine which was a Python program for Axxx of the

def is_Axxx(n): return Ayyy(n) and Azzz(n)

with a reference to the style sheet which asks programs to be self
However, when
- a sequence is defined as or equal to the intersection of A1 and A2, and
- there is no better way to characterize the terms than to check whether
they are in A1 and in A2, and
- we have the sequences Ayyy and Azzz which are characteristic functions of
A1 and A2 and provide code there to compute that in a supposedly best way

then I think it must be best practice to use these two functions, without
creating a local duplicate that would necessarily at some point in time
become obsolete w.r.t. the supposedly optimal code that can be found, just
one click away, in exactly those sequences.

Definitely, all software development guides will confirm this (avoid code
duplication and use modularity and divide-to-conquer principle) and these
very principles will be used in libraries that I could include instead of
referring to another OEIS sequence --
wouldn't that be highly illogical , if it is our aim to provide efficient
code for nontrivial sequences and we impose ourselves to use code from
elsewhere instead, when we do have our own code in the dedicated place just
one click away?

- Maximilian

More information about the SeqFan mailing list