M - M, the 1-character Map: non-nodal, non-autothreading
use M; (^3, [^4], '5')▸.Numeric.say; # (3, 4, 5)
use M '♥'; (^3, [^4], '5')♥.Numeric.say; # (3, 4, 5)
.map: *.some-method is a pretty common construct to desire in your code,
and many people choose to write it as
».some-method, using the hyper method
call. The problem is that's not always what you want and sometimes is the
wrong thing to use.
What's wrong with
»? First, it's an auto-threaded operator, which means
@foo».say won't output stuff in any predictable order. Second, it does
the whole nodal thing and descends into iterables, so that
(^3, [^4], '5')».Numeric doesn't return
(3, 4, 5).
M is here! Why
M? Cause it's a 1-character
By default, use
▸ (U+25B8) to call the hypered map (see SYNOPSIS).
If you want to use some other name for the operator, specify it as a string
use M line.
HOW DOES IT WORK?
LIMITATIONS AND TODO
Currently you can't use exported operator to map
Eventually, I hope to figure out how to make the operator available in
everywhere in the program after a single
use M anywhere,
even in scopes where
use M was not used.
Fork this module on GitHub: https://github.com/zoffixznet/perl6-M
To report bugs or request features, please use https://github.com/zoffixznet/perl6-M/issues
Zoffix Znet (@zoffix)
You can use and distribute this module under the terms of the
The Artistic License 2.0. See the
LICENSE file included in this
distribution for complete details.
META6.json file of this distribution may be distributed and modified
without restrictions or attribution.