It seems to work without spaces if you choose a symbol that is not
letter-like.

# đŸŽČU+1F3B2 Game Die
sub infix:<đŸŽČ> ( Int $num, Int $size ) { [+] (1..$size).roll($num) };
sub prefix:<đŸŽČ> ( Int $size ) { 1đŸŽČ$size }
say đŸŽČ10;
say 4đŸŽČ6;

# ⛏ U+26CF Pick
sub infix:<⛏> ( Int $num, Int $size ) { [+] (1..$size).roll($num) };
sub prefix:<⛏> ( Int $size ) { 1⛏$size }
say ⛏10;
say 4⛏6;

# Not working
# ⅆ U+2146 Double-Struck Italic Small D
#sub infix:<ⅆ> ( Int $num, Int $size ) { [+] (1..$size).roll($num) };
#sub prefix:<ⅆ> ( Int $size ) { 1ⅆ$size }
#say ⅆ10;
#say 4ⅆ6;


On 10 August 2017 at 21:16, Simon Proctor <simon.proc...@gmail.com> wrote:

> So I had a crazy little idea. I've played the odd bit of roleplaying in my
> time and wanted to created a 'd' operator.
>
> Quite simple really.
>
> sub infix:<d> ( Int $num, Int $size ) { [+] (1..$size).roll($num) };
>
> sub prefix:<d> ( Int $size ) { 1 d $size }
>
> Gives us 3 d 6 to roll 3 six sided dice or a prefix d 10 for a single 10
> sided dice.
>
> Except... I'd really like to write 3d6 or d10 but the parser barfs.
>
> Am I going to just have to live with that? Or did I miss something
> obvious?
>
> Obviously it's possible to have operators that ignore whitespace (1+1
> works just fine) but is it possibly for user defined ones?
>
> Possibly more serious ones.
>
> Simon
>



-- 
Norman Gaywood, Computer Systems Officer
School of Science and Technology
University of New England
Armidale NSW 2351, Australia

ngayw...@une.edu.au  http://turing.une.edu.au/~ngaywood
Phone: +61 (0)2 6773 2412  Mobile: +61 (0)4 7862 0062

Please avoid sending me Word or Power Point attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html

Reply via email to