infix ∘
1 | language documentation Operators |
1.1 | (Operators) infix ∘ |
Documentation for infix ∘
assembled from the following types:
language documentation Operators
From Operators
(Operators) infix ∘
multi sub infix:<∘>()multi sub infix:<∘>()multi sub infix:<∘>(, --> Block)
The function composition operator infix:<∘>
or infix:<o>
combines two functions, so that the left function is called with the return value of the right function. If the .count
of the left function is greater than 1, the return value of the right function will be slipped into the left function.
Both .count
and .arity
of the right-hand side will be maintained.
sub f()sub g()my = ∘ ;say composed 2; # OUTPUT: «gf2»# equivalent to:say 2..;# or to:say f g 2;
sub f(, , )sub g()my = ∘ ;say composed 'abc'; # OUTPUT: «cba»# equivalent to:say f |g 'abc';
The single-arg candidate returns the given argument as is. The zero-arg candidate returns an identity routine that simply returns its argument.
my = [∘] ;say composed 'foo'; # OUTPUT: «FOO»my = [∘];say composed 'foo'; # OUTPUT: «foo»