What about the function compose() that would live in the module
"keyword", imported by the incantation "use keyword qw( compose );"?
(NB: My P6-fu sucks right now)
multimethod compose (@*List) {
return {
$_() for @List;
};
}
On 5/4/05, Michele Dondi <[EMAIL PROTECTED]> wrote:
> I had implicitly touched on this in the past, but speaking of binops - and
> of functional features in Perl6, is there any provision of a (list
> associative?) composition binop?
>
> I had naively thought about ==> and/or <==, but that's somewhat on a
> different level.
>
> What I refer to now is something that takes two {coderefs,anonymous
> subs,closures} and returns (an object that behaves like) another anonymous
> sub, precisely the one that acts like the former followed by the latter
> (or vice versa!).
>
> Optionally, (ab)using C<< ==> >> for it, if we have
>
> my $composed = sub_1 ==> sub_2;
>
> and sub_1 has a signature, and sub_2 has a returns trait, $composed should
> have the same signature as sub_1 and the same returns trait as sub_2. Also
> it should complain if sub_2 has a signature and sub_1 a returns trait and
> these do not match.
>
> How 'bout this idea?
>
> Michele
> --
> L'amava come si ama qualcosa che e' necessario alla vita.
> La odiava come si odia chi tradisce.
> - Laura Mancinelli, "Gli occhi dell'imperatore"
>