def sort(self,key=None,buffer=1000): return Sequence(itertools2.sorted_iterable(self, key, buffer))
def sort(self, key=None, buffer=100): return Sequence(itertools2.sorted_iterable(self, key, buffer))
desc="Smallest member 'a' of the primitive Pythagorean triples (a,b,c) ordered by increasing c, then b" A046086=Sequence(math2.primitive_triples,desc=desc).apply(lambda x:x[0]) # .sort(key=lambda x:x[2]) \ #not needed anymore # .apply(lambda x:x[0]) """ found a bug in OEIS ! 20th term of the serie is 145, not 142 ! desc="Hypotenuse of primitive Pythagorean triangles sorted on area (A024406), then on hypotenuse" A121727=Sequence(math2.primitive_triples,desc=desc) \ .sort(lambda x:(x[0]*x[1],x[2])) \ .apply(lambda x:x[2]) """ # Build oeis dict by module introspection : Simple and WOW ! seqs=globals().copy() oeis={} for id in seqs: if id[0]=='A' and len(id)==7: seqs[id].name=id oeis[id]=seqs[id] if __name__ == "__main__": """local tests""" it=itertools2.sorted_iterable(math2.primitive_triples(),(lambda x:(x[0]*x[1],x[2]))) for p in itertools2.take(30,it): print(p,p[0]*p[1]/2)