News for hackers. Stuff that matters.
Re:Using Python generators for real work [pdf] by ot on Sunday January 23, 2011 @05:54PM (#2133561)
It seems that pipeline-style programming is now popular in many modern programming languages, for example C# (with Linq), F# (with the |> pipe operator and the Seq module), and Ruby and JS+jQuery (with method chaining).

I really wish Python had some syntactic feature that encourages this style, doing "gen_cat(gen_open(gen_find(...)))" is rather cumbersome, compared to "gen_find(...) | gen_open | gen_cat".

Of course you can override __or__ like some libraries do, but it is not the One Way To Do It...

Re:Using Python generators for real work [pdf] by xtacy on Sunday January 23, 2011 @06:29PM (#2133650)
Mathematica has a nice syntax for function application, mapping over lists, etc. It's also possible to define such operators in Haskell, which has the added advantage of type-safety.

  f @ {1,2,3} == f[{1,2,3}]
  f /@ list == map(f, list)
  f @@ {1,2,3} == f[1,2,3]

  (#1 * 2) /@ {1,2,3} == {2,4,6}
etc.
Re:Using Python generators for real work [pdf] by ot on Sunday January 23, 2011 @06:42PM (#2133682)
That's like F# operator |>

    f |> g == g(f)
    [1 .. 3] |> Seq.map (fun x -> x * x) |> Seq.sum |> printfn "%A" // prints 14
Re:Using Python generators for real work [pdf] by lloeki on Monday January 24, 2011 @12:52PM (#2135921)
Someone took an interesting stab at it: http://stackoverflow.com/questions/2281693/is-it-a-good-idea...

Sadly this is one of the reasons I still write shell scripts: pipes are so explicit and compact. Python seems to gather more of a practical functional crowd these times around.

Re:Using Python generators for real work [pdf] by Tyr42 on Monday January 24, 2011 @01:04AM (#2134439)
I like Haskell's function composition syntax: .

(f . g)(x) = f(g(x))

cat.open.find ...