News for hackers. Stuff that matters.
Re:Pointfree style in Python by perfunctory on Monday November 14, 2011 @11:30AM (#3234550)
I appreciate the beauty of the pointfree style but whenever I tried to use it I found that I couldn't read my own code the next day. It seems that my brain is just hard wired to expect a list of parameters in a function definition.

EDIT: That is, all these years at school I was taught to write f(x) = x^2, not f = (^2).

Re:Pointfree style in Python by jerf on Monday November 14, 2011 @03:03PM (#3235445)
I don't think a Haskeller should try to use point-free code. It's just that if you're refactoring your code and you get it down to the point that you've got

   thing x = th . in . g x
you might as well finish the job and take the x out. What's left should make sense to you if you follow this process and just let it happen. But I feel no shame when I can't go pointfree, especially when pointfree requires crazy hacks to simulate a simple pattern match.
Re:Pointfree style in Python by JadeNB on Monday November 14, 2011 @03:22PM (#3235534)
Sorry, but, aside from the obviously unimportant use of `in` (a reserved word), this gives a different type from what I think you meant:

    x :: a
    g :: a -> b -> c
    in :: c -> d
    th :: d -> e
    thing :: a -> b -> e
and naïve eta-conversion will give you something that isn't well typed. Probably you meant

    thing x = th . in . g $ x
Re:Pointfree style in Python by jerf on Monday November 14, 2011 @03:59PM (#3235671)
Yes, thanks.
Re:Pointfree style in Python by eru on Monday November 14, 2011 @02:40PM (#3235352)
They should have told you write f = (x -> x^2) or so.
Re:Pointfree style in Python by JadeNB on Monday November 14, 2011 @03:23PM (#3235540)
I think it's better pedagogically just to acknowledge that, in common mathematical discourse, "the squaring function" doesn't have any symbolic name. Perhaps it's more illustrative to think of, for example, `f(x) = ln(x)` (the value of a function) versus `f = ln` (the function itself); and a good (college) mathematics teacher will make this distinction.
Re:Pointfree style in Python by perfunctory on Tuesday November 15, 2011 @03:19AM (#3237512)
They could also tell me to write (= f (-> (x) (^ x 2))). Then we would all be using lisp and laughing and those few developers who would using that weird infix notation.
Re:Pointfree style in Python by eru on Tuesday November 15, 2011 @01:38PM (#3239453)
While I like S-Expressions for computers, even in that small example the parenthesis are a bit excessive. Keep in mind that mathematics is mostly written by hand on a black board.
Re:Pointfree style in Python by JadeNB on Tuesday November 15, 2011 @09:24PM (#3241433)
Ah, so it's postfix you want?

    fxx2^1+→=
:-)
Re:Pointfree style in Python by eru on Tuesday November 15, 2011 @10:35PM (#3241619)
On a blackboard I want to (ab)use that I have a nice and flat surface, and don't have to be restricted to linear strings of characters.