a draft module (funky.py) -- digital math track

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

a draft module (funky.py) -- digital math track

kirby urner-4
"""
non-axial:  10 FF + 2 is the classic CCP number
sequence (OEIS A005901).

Here we bring out the +2 associated with polar
vertexes by means of function composition, applied
using decorator syntax (@)

[12, 42, 92, 162, 252, 362, 492, 642, 812, 1002]

Note how a "double decorator" makes sense
as well (the output function is fed back in
to compose and output once again ala g(g(f(x)).

[4, 5, 6, 7, 8, 9, 10, 11, 12, 13]

brainstorming posters for Pycon / Havana; Pycon / Ukraine

Bibliography:

The King of Infinite Space (bio of HSM Coxeter)
Proof of 10FF + 2 (NCLB project)

"""

def compose( f ):
    global g
    return lambda x:  g( f (x) )

def g(x):  return x + 2

@compose
def nonaxial(n):  return 10 * n * n

@compose
@compose
def identity(x):  return x


def test():
    print ( [ nonaxial(x) for x in range(1, 11) ] )
    print ( [ identity(x) for x in range(10) ] )

if __name__ == "__main__":
    test()
    



_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig