On 8.5.2015 8:19, Rustom Mody wrote:
On Wed, May 6, 2015 at 6:45 PM, Ivan Levkivskyi <levkivskyi@gmail.com> wrote:

def sunique(lst):
    return sorted(list(set(lst)))


sunique = sorted @ list @ set

I would like to suggest that if composition is in fact added to python its order is 'corrected'
ie in math there are two alternative definitions of composition

[1] f o g = λ x • g(f(x))
[2] f o g = λ x • f(g(x))

[2] is more common but [1] is also used

And IMHO [1] is much better for left-to-right reading so your example becomes
sunique = set @ list @ sorted
which reads as smoothly as a classic Unix pipeline:

"Unnamed parameter input to set; output inputted to list; output inputted to sort"

While both versions make sense, [2] is the one that resembles the chaining of linear operators or matrices, since column vectors are the convention. For the left-to-right pipeline version, some other operator might be more appropriate. Also, it would then be more clear to also feed x into the pipeline from the left, instead of putting (x) on the right like in a normal function call.

As a random example, (root @ mean @ square)(x) would produce the right order for rms when using [2].

-- Koos