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

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-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]}

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