C++ vs Lisp

Dee Girl deegirl at noreply.com
Sat May 17 15:53:44 PDT 2008


Neal Alexander Wrote:

> Nick Sabalausky wrote:
> > "Neal Alexander" <WQEQWEUQY at HOTMAIL.COM> wrote in message 
> > news:g0nha0$1s9l$1 at digitalmars.com...
> >> - Function composition: (process . reverse . sort) list
> >> vs
> >> process(reverse(sort(list)))
> >>
> > 
> > Did you mean:
> > 
> > (sort . reverse . process) list
> > vs
> > process(reverse(sort(list)))
> > 
> > Or does Haskell put them in order of (last . first)?  FWIW, I really like 
> > the style I've seen in some languages that's basically:
> > 
> > list.sort().reverse().process()
> > vs
> > process(reverse(sort(list)))
> > 
> > Which, I'm assuming is what you're talking about, but not certain. 
> > 
> > 
> Nah its read right to left.
> 
> "(f . g) x" is the same as "f (g x)"
> 
> http://en.wikipedia.org/wiki/Function_composition_(computer_science)
> 
> Anyway, its similar to list.sort().reverse().process() in that you can 
> create pipelines like that. But its different in that it joins two 
> functions to create a new one - without having to apply any arguments to 
> it right away.
> 
> list.sort().reverse().process() can be looked at as a Monad too i guess.
> 
> "process =<< reverse =<< sort =<< return list"
> 
> (right to left again - with sort, reverse, and process allowing side 
> effects)

This is so beautiful in new pipe in std.functional. Because you can group intuitive left to right. And does good work as compose! I look at definition it is this:

template pipe(fun...)
{
    alias compose!(Reverse!(fun)) pipe;
}

I am not 100% sure but think there is no new function, just rename of compose. So no runtime work. Very nice. Dee Girl



More information about the Digitalmars-d mailing list