Created
August 12, 2021 11:11
Revisions
-
Xliff created this gist
Aug 12, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,54 @@ ```raku use v6; package Bizzell::Operators { multi sub postfix:<seconds> ($a) { $a; } multi sub postfix:<minutes> ($a) { $a * 60; } multi sub postfix:<hours> ($a) { $a * 3600 * 3600 } multi sub postfix:<days> ($a) { $a * 86400; } } sub EXPORT { Map.new( '&postfix:<seconds>' => &Bizzell::Operators::postfix:<seconds>, '&postfix:<s>' => &Bizzell::Operators::postfix:<seconds>, '&postfix:<minutes>' => &Bizzell::Operators::postfix:<minutes>, '&postfix:<m>' => &Bizzell::Operators::postfix:<minutes>, '&postfix:<hours>' => &Bizzell::Operators::postfix:<hours>, '&postfix:<h>' => &Bizzell::Operators::postfix:<hours>, '&postfix:<days>' => &Bizzell::Operators::postfix:<days>, '&postfix:<d>' => &Bizzell::Operators::postfix:<days> ) } ``` Now getting the basics of this is easy. I could add "is export" to the definitions in Bizzell::Operators and call it a day, but what would be the easy way of adding the associated aliases that would make this expression: ``` 4days + 8hours + 10minutes - 1second ``` Turn into the much more elegant: ``` 4d + 8h + 10m - 1s ``` BTW -- the above does NOT work.