Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Babbys first Python Fibonacci

Name: Anonymous 2011-11-28 7:40


from sys import argv
script, n = argv

f = lambda x: x and (x-1 and x-2 and f(x-1) + f(x-2) or 1)
print f(int(n))

Name: Anonymous 2011-11-28 7:42

Babbys first
Back to /v/, ``please''!!

Name: Anonymous 2011-11-28 7:42

poledog kebabz

Name: Anonymous 2011-11-28 7:53

polecat vakbobs

Name: Anonymous 2011-11-28 9:21

Babbys first numerical methods!


from math import *

start = 0
end = 10
polynomial = lambda x: x**2

I = lambda f, s, e, v: reduce(lambda k,l: k + l*v,
                              map(f,
                                  map(lambda k: float(k)*v,
                                      range(int(s/v), int(e/v)))))

previous = 0
for n in range(0,10):
    interval = 1.0/(2**n)
    print "Integrating x^2 from %d to %d using interval %f:" % (
        start, end, interval)
    integral = I(polynomial, 0, 10, interval)
    print "%f (difference to previous calculation %f)" % (
        integral, integral-previous)
    previous = integral

Name: Anonymous 2011-11-28 14:33

Enjoy your crippled lambdas.

Name: Anonymous 2011-11-28 16:16

>>1'
>2011
>still writing out `and' and `or' rather then using symbols

Name: Anonymous 2011-11-28 17:32

>>7
cancer of the semicolon

Name: Anonymous 2011-11-28 17:59

>>8'
>using a ; to represent `and' or `or'


no one does this

Name: Anonymous 2011-11-28 20:38

>>9
Please leave the programming board.

Name: Anonymous 2011-11-28 20:46

I found you're post truly amusing, >>10 -kun.

Don't change these.
Name: Email:
Entire Thread Thread List