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

Pages: 1-

Learning Python

Name: Anonymous 2011-03-09 23:01

Hi /prog/. I only know Haskell and Perl, and have decided to try learning Python. Here's a program I wrote as a simple exercise, it sorts user-entered numbers by putting them into a binary tree. Could you please look over it and maybe give me some suggestions? Thanks.

print ''.join([str(node) + '\n' for node in [print_tree for print_tree in [lambda t: (len(t) == 0 and (lambda t2: t2) or (lambda t2: print_tree(t2[0]) + [t2[1]] + print_tree(t[2])))(t)]][0]([get_tree for get_tree in [lambda t: [(num == 0 and (lambda t2: t2) or (lambda t2: [insert for insert in [lambda x, t: len(t) == 0 and [[], x, []] or (x < t[1] and [insert(x, t[0])] + t[1:] or t[:2] + [insert(x, t[2])])]][0](num, get_tree(t2))))(t) for num in [input('Enter a number (0 to stop): ')]][0]]][0]([]))]),

Name: Anonymous 2011-03-09 23:02

PYTHONIC AS FUCK

Name: Anonymous 2011-03-09 23:03

I love you, you magnificent bastard.

Name: Anonymous 2011-03-09 23:24

0↵

Name: Anonymous 2011-03-09 23:31

Holly . . . fuck

Name: Anonymous 2011-03-09 23:33

it actually fucking works!

Name: Anonymous 2011-03-10 0:23

Your code is awful! Even in my immature Lisp DSL I did the same stuff in two lines:

yoba tree=[] -> say nl=no "Enter a number (0 to stop): "
             -> read |> {0->map lhd tree; n->yoba tree=[n=1@tree]}

Name: Anonymous 2011-03-10 0:45

>>2-6
Hello, >>1-san!

Name: Anonymous 2011-03-10 0:51

>>8

fuck you faggot, die in a fire

Name: Anonymous 2011-03-10 1:27

>>8
Nope.

Name: Anonymous 2011-03-10 3:51

Don't see >>7's posts!

Name: Anonymous 2011-03-10 5:44

>>1
ONE WORD: THE FORCED ONE-LINERS TO AVOID THE FORCED INDENTATION OF CODE. THREAD OVER
>>7
ONE WORD: THE FORCED GENERALIZATION OF DOMAIN-SPECIFIC-LANGUAGES. THREAD OVER

Name: Anonymous 2011-03-10 17:53

>>12
You fail to realize that is in fact several words.

Name: Anonymous 2011-03-10 18:15

>>7
I did the same stuff in two lines:
>>> 2 < 1
False

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