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

Functional programming in Python

Name: Anonymous 2008-04-27 5:16

I really like functional, it's what Python should have been to start with. Too bad Guido is taking the language in the complete wrong direction.
If I had the inclination, I'd make a fork of Python, get rid of the FIOC, classes, and all that other crap, make print etc. into real functions, and turn it into a real functional programming language.

Oh, and:
print(eval((lambda: '\n'.join(map(reduce(compose, (''.join, partial(starmap,
apply), partial(flip(zip), map(c, (compose(*map(itemgetter, map(int, oct(1))
)), itemgetter(2), compose(*map(itemgetter, map(int, repr(11))))))), repeat,
partial(partial, flip(apply)), c)), sorted(izip(imap(randrange, repeat(int(a
, 36))), chain(starmap(map, zip(map(partial(partial, flip(mod)), 'aa b i u '
's o spoiler code sup sub'.split()), repeat('[%s] [/%s]'.split()))), c('> 0'
'&2;3+'.partition(''.join(imap(compose(chr, partial(xor, 229)), starmap(add,
izip(*imap(partial(imap, ord), (a, b)))))))[::2])), repeat(reduce(add, imap(
partial(getitem, reduce(add, imap(chr, starmap(add, izip(chain(imap(compose(
partial(flip(sub), 108), ord), '+kquuv'), repeat(mod(reduce(add, map(ord, b)
), div(int(a, 36), 4197516)))), imap(ord, compose(partial(imap, itemgetter(0
)), groupby)(sorted(reduce(add,(a, b)))))))))), map(int, '%d' * 0x6 % tuple(
map(compose(partial(flip(sub), 42), ord), (reduce(add, map(reduce(compose, (
chr, partial(add, 0x2f), partial(apply, sub))), zip(*map(tuple, map(partial(
map, ord), (b, 'c Sti-')))))))))))))))))).func_code, (lambda n, g = dict(zip
('abc', ('bbcode', 'satori', lambda *c: c))): (map(g.update, ((__import__(m)
).__dict__ for m in n)), g)[1])('random functional operator itertools'.split
())))

Name: Anonymous 2008-04-28 22:43

>>25

I'm talking about all the crap like <- -> => >> >>= !! \ ++ :: : . | ||, rather than functions with sensible names. If you want some examples in context, here's a bit from the official Haskell website:
the third function is known as "bind" but is written ">>="
(>>=) :: m a -> (a -> m b) -> m b

What the fuck, why not just call the goddamn thing "bind". Instead of three meaningless-looking punctuation characters, you'd be typing four actual letters, which you can actually fucking read and make sense of at first glance. If nothing else, you can at least infer then that it BINDS something.

Incidentally, this is why I like Python so much: typically it's extremely easy to jump into a program and get an idea of what's going on. Haskell coders love to take advantage of the fact that you can express practically everything without even typing any letters.

I've been continually told that xmonad is "really easy to understand" and that "you don't need to know any Haskell, you can just figure everything out by looking at it". These are actual statements made by xmonad users, mind.

    , ((modMask              , xK_b     ),
          modifyGap (\i n -> let x = (XMonad.defaultGaps conf ++ repeat (0,0,0,0)) !! i
                             in if n == x then (0,0,0,0) else x))


Or how about this:
    [((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f))
        | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
        , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]

Where does that .|. come from? I don't think I've ever encountered a penis operator before.

Haskell is full of shit like that, and if you somehow think it's even nearly as straightforward to read as typical Python (or even Perl) code, you're only fooling yourself.

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