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 2010-12-08 15:34

I AM THE MOST FUCKING NGGER MATURE

GIVE ME BACK THE PASSWORD

Name: Anonymous 2010-12-08 15:47

These need to be done: C, C++, C# (and with XNA), Java, HTML, JavaScript, CSS, XML, SQL, LISP

Name: Anonymous 2010-12-09 15:52

>>282
samefag here, BUMP

Name: Anonymous 2010-12-09 15:56

>>279
I hope that's binary, chap.

Name: Anonymous 2010-12-09 16:04

This is the best thread in /prog/

We should shut down this place

Name: Anonymous 2010-12-09 18:18

This thread has 286 replies

Name: Anonymous 2010-12-09 18:35

You can't reply anymore.

Name: Anonymous 2010-12-09 18:40

This thread is threadstopped.

Name: Anonymous 2010-12-09 20:20

i lold

Name: Anonymous 2010-12-09 21:21

This thread has been lolstopped. You can't lol anymore.

Name: Anonymous 2010-12-09 22:03

*muffled laughter*

Name: Anonymous 2010-12-10 0:17

This thread has been ejaculatestopped. You can't ejaculate anymore.

Name: me 2011-01-20 19:00

42

Name: Anonymous 2011-01-20 19:26

>>289
nice.

Name: Anonymous 2011-01-20 19:27

My other mapM_ fold is a Segmentation fault

Name: Anonymous 2011-01-20 19:30

>>295
I actually lol'd.

Name: Anonymous 2011-01-21 4:23

>>295
I laughed much more than I should've.

Name: Anonymous 2011-01-21 5:50

My other errno is an ENOSYS.

Name: Anonymous 2011-01-21 13:12

>>298
My other errno is a [codeGetLastError(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);[/code]

Name: Anonymous 2011-01-21 14:59

<---- check em dubz

Name: Manuel 2011-02-16 2:59

please,add me.
msn:xyr_lili@hotmail.com
remake:C/C++ programmer

Name: sage 2011-02-18 17:05

Name: Anonymous 2011-02-24 9:48

sage

Name: Anonymous 2011-03-03 12:29

>>295
nice.

Name: Anonymous 2011-03-03 13:47

C#

static int Fatorial(int fat)
        {
            int resultado = fat;
            for(int i = fat - 1;i>0;i--)
            {
                resultado *= i;   
            }
           
            return resultado;
        }

Name: Anonymous 2011-03-03 14:02

>>305
That's it. I'm calling all my to-be-returned variables resultado from now on.

Name: Anonymous 2011-03-03 16:34

static int
Factorial
        (
 int fat
)
                     {
 int resultado = fat;
 for                 (
     int i = fat - 1;
     i < 0;
     i--
    )
                    {
     resultado *= i;
    }
 return resultado;
}

Name: Anonymous 2011-03-03 17:14

>>305,307
resultado
What natural language is that?

Name: Anonymous 2011-03-03 17:18

>>308

>>305 here, it's portuguese. Iḿ from Brazil.

Name: Anonymous 2011-03-03 18:06

>>309
I didn't ask where you're from. Why do Brazilians feel this compulsion to tell you they're from Brazil? No one cares, dude.

Name: Anonymous 2011-03-03 18:47

>>310
BR?

Name: Anonymous 2011-03-03 19:29

>>310

Altough a "default" portuguese language set of rules has been recently approved by all portuguese-speaking countries, there are still differences. That was just to clarify, I'm not compulsive. I've been around for quite a time and never said it, right?

>>311


while(true)
{
printf("BR?");
}

Name: Anonymous 2011-03-03 19:38

>>312
while(puts("BR"));

Name: Anonymous 2011-03-03 20:24

>>312
Altough a "default" portuguese language set of rules has been recently approved by all portuguese-speaking countries, there are still differences.
Do those differences apply to the word ``resultado''?
I've been around for quite a time and never said it, right?
Somehow your posting of a uninteresting factorial implementation written in C# on this particular thread makes me doubt that.

Name: Anonymous 2011-03-03 20:33

class Brazilian
  @@hello_good_sir = 'AEHAUEHAUHEUAHEUAEHUAEHUAEHEUHEUAHEUHEU'
  @@are_you_from_the_southern_lands = 'BR?'
  while true do
    puts @@hello_good_sir
    3.times { puts @@are_you_from_the_southern_lands }
  end
end

three_o_zero_kun = Brazilian.new

Name: Anonymous 2011-03-03 21:18

>>314
No.

>>312
I would hardly call the latest spelling reform as a new ``default set of rules'' across multiple countries. There's still a long way to go until that happens.

Name: Anonymous 2011-03-03 21:37

>>307
who the fuck indents like that

Name: Anonymous 2011-03-04 5:59

>>317
That's the official /prog/'s indentation style.

Name: Anonymous 2011-03-04 6:17

>>314

I just felt like posting things other than /prog and [spoiler][b][i]AUTISM[/b][/i][/spoiler].

And no, resultado wasn't affected. I just wrote all that crap because the voices in my head ECHO'd them.

>>316

Yes. But just for something so crappy to be commonly accepted was already a huge step backwards. They just made things written wrong work somewhat right.

Name: Anonymous 2011-03-04 6:24

>>319
BBCode AMATEUR DETECTED!!!

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