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

Evolution of a Python programmer

Name: Anonymous 2007-05-25 5:34 ID:e87L90K/


#Newbie programmer
def factorial(x):
    if x == 0:
        return 1
    else:
        return x * factorial(x - 1)
print factorial(6)


#First year programmer, studied Pascal
def factorial(x):
    result = 1
    i = 2
    while i <= x:
        result = result * i
        i = i + 1
    return result
print factorial(6)


#First year programmer, studied C
def fact(x): #{
    result = i = 1;
    while (i <= x): #{
        result *= i;
        i += 1;
    #}
    return result;
#}
print(fact(6))


#First year programmer, SICP
@tailcall
def fact(x, acc=1):
    if (x > 1): return (fact((x - 1), (acc * x)))
    else:       return acc
print(fact(6))


#First year programmer, Python
def Factorial(x):
    res = 1
    for i in xrange(2, x + 1):
        res *= i
    return res
print Factorial(6)


#Lazy Python programmer
def fact(x):
    return x > 1 and x * fact(x - 1) or 1
print fact(6)


#Lazier Python programmer
f = lambda x: x and x * f(x - 1) or 1
print f(6)


#Python expert programmer
import operator as op
import functional as f
fact = lambda x: f.foldl(op.mul, 1, xrange(2, x + 1))
print fact(6)


#Python hacker
import sys
@tailcall
def fact(x, acc=1):
    if x: return fact(x.__sub__(1), acc.__mul__(x))
    return acc
sys.stdout.write(str(fact(6)) + '\n')


#EXPERT PROGRAMMER
import c_math
fact = c_math.fact
print fact(6)


#ENGLISH EXPERT PROGRAMMER
import c_maths
fact = c_maths.fact
print fact(6)


#Web designer
def factorial(x):
    #-------------------------------------------------
    #--- Code snippet from The Math Vault          ---
    #--- Calculate factorial (C) Arthur Smith 1999 ---
    #-------------------------------------------------
    result = str(1)
    i = 1 #Thanks Adam
    while i <= x:
        #result = result * i  #It's faster to use *=
        #result = str(result * result + i)
           #result = int(result *= i) #??????
        result str(int(result) * i)
        #result = int(str(result) * i)
        i = i + 1
    return result
print factorial(6)


#Unix programmer
import os
def fact(x):
    os.system('factorial ' + str(x))
fact(6)


#Windows programmer
NULL = None
def CalculateAndPrintFactorialEx(dwNumber,
                                 hOutputDevice,
                                 lpLparam,
                                 lpWparam,
                                 lpsscSecurity,
                                 *dwReserved):
    if lpsscSecurity != NULL:
        return NULL #Not implemented
    dwResult = dwCounter = 1
    while dwCounter <= dwNumber:
        dwResult *= dwCounter
        dwCounter += 1
    hOutputDevice.write(str(dwResult))
    hOutputDevice.write('\n')
    return 1
import sys
CalculateAndPrintFactorialEx(6, sys.stdout, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)


#Enterprise programmer
def new(cls, *args, **kwargs):
    return cls(*args, **kwargs)

class Number(object):
    pass

class IntegralNumber(int, Number):
    def toInt(self):
        return new (int, self)

class InternalBase(object):
    def __init__(self, base):
        self.base = base.toInt()

    def getBase(self):
        return new (IntegralNumber, self.base)

class MathematicsSystem(object):
    def __init__(self, ibase):
        Abstract

    @classmethod
    def getInstance(cls, ibase):
        try:
            cls.__instance
        except AttributeError:
            cls.__instance = new (cls, ibase)
        return cls.__instance

class StandardMathematicsSystem(MathematicsSystem):
    def __init__(self, ibase):
        if ibase.getBase() != new (IntegralNumber, 2):
            raise NotImplementedError
        self.base = ibase.getBase()

    def calculateFactorial(self, target):
        result = new (IntegralNumber, 1)
        i = new (IntegralNumber, 2)
        while i <= target:
            result = result * i
            i = i + new (IntegralNumber, 1)
        return result

print StandardMathematicsSystem.getInstance(new (InternalBase, new (IntegralNumber, 2))).calculateFactorial(new (IntegralNumber, 6))

Name: Anonymous 2007-05-25 20:50 ID:mHFMDOiL

>>40
you are both wrong, IVE READ SICP, everyone else hasnt'

Name: Paul Graham 2007-05-25 21:10 ID:Heaven

HI, I'M PAUL GRAHAM, FOUNDER AND CEO OF Y COMBINATOR. I HAVE MADE MANY INSIGHTFUL STATEMENTS IN MY ESSAY ENTITLED "YOUR MOTHER AND THE 48 VERY SMART PEOPLE" AND WOULD LIKE TO THANK TREVOR BLACKWELL, ROBERT MORRIS AND JESSICA LIVINGSTON FOR HAVING READ DRAFTS OF THIS ESSAY, WHICH YOU WILL BE ABLE TO FIND WITH 21 OTHERS ESSAYS IN MY UPCOMING BOOK "HACKERS AND YOUR SISTER". I GUARANTEE IT.

Name: Anonymous 2007-05-25 21:50 ID:Y0k+aF+t

You forgot Java.

Name: Anonymous 2007-05-25 22:02 ID:kTKPP7F5

>>43

It looks like enterprise.

Name: Anonymous 2007-05-25 22:22 ID:mHFMDOiL

>>42
ROFL

Name: redir 2007-05-25 22:54 ID:TDz4ykBW

def factorial(x)
    print [n for n in range(2, x + 1)]

Name: Anonymous 2007-05-25 23:21 ID:r00B89jk

Hay guys, I think you just spread the enterprise meme to reddit.

Name: redir 2007-05-25 23:35 ID:TDz4ykBW

erm I meant:

def fact(x):
    r = 1
    for x in (n for n in range(1, 9 + 1)):   r*=x
    return r


damn hangover....

Name: Anonymous 2007-05-25 23:46 ID:p9Rnzt89

Web designer should be

def factorial(x):
    #-------------------------------------------------
    #--- Code snippet from The Math Vault          ---
    #--- Calculate factorial (C) Arthur Smith 1999 ---
    #-------------------------------------------------
    result = str(1)
    i = 1 #Thanks Adam
    while i <= x:
        #result = result * i  #It's faster to use *=
        #result = str(result * result + i)
           #result = int(result *= i) #??????
        #result str(int(result) * i)
        result = str(int(result) * i) #Thanks Anon
        #result = int(str(result) * i)
        i = i + 1
    return result
print factorial(6)

Name: Anonymous 2007-05-26 0:53 ID:KQr4fWNP

>>49
Fail, web designers don't know the meaning of anonymous.

Also, 50GET.

Name: Anonymous 2007-05-26 1:17 ID:QVvIyB+F

mu?

Name: Chris Rathman 2007-05-26 2:54 ID:VUtNl2ok

Well, as long as you're replicating some of the Haskell examples, you can throw in:

<pre>
  # Boy Scout Programmer
  y = (lambda le:
         (lambda f: f(f))
            (lambda f:
               le(lambda x: f(f)(x))))
  fac = y(lambda f: lambda n: 1 if (n == 0) else n*f(n-1))
</pre>

Name: Anonymous 2007-05-26 3:10 ID:aZuUXba6

lol, reddit is full of fags now that half the digg userbase have joined them

Name: anon 2007-05-26 6:31 ID:hqSnH5K8

dude that was hilarious.. the MS one is so true..

Name: Anonymous 2007-05-26 6:50 ID:Heaven

http://programming.reddit.com/info/1tjui/comments/c1tlx6
I'd give this an upvote if I didn't know that nothing of value ever comes from 4chan and this therefore cannot possibly be original. Still, some funny stuff!
No original content?
print "reddit == fags"

Name: Mope 2007-05-26 12:36 ID:IFYadk/9


# Numeric Python programmer
import Numeric as N         ; mulR = N.multiply.reduce
# for n <= 170
def nFactorial(n,A=N.arange(1.,171.)): return mulR(A[:n])  

Name: damn 2007-05-26 13:14 ID:mot+LDOi

def fact(x):
    r = 1
    for i in (n for n in range(1, x + 1)): r*=i
    return r

see what happens when you don't sleep.

Name: Anonymous 2007-05-26 14:05 ID:KQr4fWNP

>>53
Reddit was always full of fags and now it's just gotten worse.

Name: Anonymous 2007-05-26 14:34 ID:ZnydAF6M

Faggotry of a Python faggot.

Name: Anonymous 2007-05-26 14:56 ID:VBd4YYKx

This thread was created with the mistaken impression that python programmers -evolve- when in reality they do the exact opposite.

Name: Anonymous 2007-05-26 16:10 ID:Dh7r8SzC

>>60

Whip it; whip it good.

Name: mope 2007-05-26 18:14 ID:IFYadk/9

For x>13 Your "Python expert programmer" solution

   fact = lambda x: reduce(int.__mul__, xrange(2, x + 1), 1)

throws a TypeError (__mul__ wants int, received a long).

For Python version >=? this works for arbitrarily big numbers:

   fact = lambda x: reduce(long.__mul__,map(long,range(1,x)),1L)

Name: pascalito 2007-05-26 18:27 ID:liLMXNTh

this is another way with pascal as a background:

def PascalFact(x):
    f = 1
    for x in range(x):
        f *= x+1
    return f

Name: Anonymous 2007-05-26 22:27 ID:Heaven

wtf is with all these mailfags
gb2/reddit/ goddamnit

Name: Anonymous 2007-05-27 2:00 ID:SYhtwuRM

lambda x: eval("*".join(str(i) for i in xrange(2, x + 1)))

Name: Anonymous 2007-05-27 7:54 ID:Oyo93YKn

>>65
Awesome

Name: Anonymous 2007-05-27 14:56 ID:Heaven

HI, I'M PAUL GRAHAM, FOUNDER AND CEO OF Y COMBINATOR. I HAVE MADE MANY INSIGHTFUL STATEMENTS IN MY ESSAY ENTITLED "YOUR MOTHER AND THE 48 VERY SMART PEOPLE" AND WOULD LIKE TO THANK TREVOR BLACKWELL, ROBERT MORRIS AND JESSICA LIVINGSTON FOR HAVING READ DRAFTS OF THIS ESSAY, WHICH YOU WILL BE ABLE TO FIND WITH 21 OTHERS ESSAYS IN MY UPCOMING BOOK "HACKERS AND YOUR SISTER". I GUARANTEE IT.

Name: Anonymous 2007-06-04 2:20 ID:bKJWS5eC

fucktards

Name: Anonymous 2007-06-04 3:07 ID:r9m8Xvz2

EXPERT PERL PROGRAMMER:
eval join'*',2..$n

Name: Anonymous 2007-07-10 18:37 ID:MA5k4FA0

dfghjkjhgfdddddd

Name: Anonymous 2007-07-10 19:01 ID:Heaven

Evolution of a SAGE

Name: Nobody 2007-07-15 6:10 ID:P6y9K1HM

I have just stumbled upon this odd shambles of tripe, what a strange world the web can be...

Name: Anonymous 2007-07-15 6:39 ID:Heaven

>>76
Kill yourself

Name: Anonymous 2007-07-17 4:24 ID:Heaven

>>19
It's funnier with the typo in the web programmer's version.

Name: Anonymous 2007-07-17 9:09 ID:WPxdirIw

Na Izumiya staat Hosokin op het programma. Hier bekijken we enkel de tosai en bestellen er enkele honderden. ... Na Hosokin

Name: Anonymous 2007-07-17 10:18 ID:S+zat9h1

>>79

Wat de neuk is een tosai? Gekke wapanees.

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