Re: User defined infix operators and whitespace

2017-08-26 Thread Norman Gaywood
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

Re: User defined infix operators and whitespace

2017-08-10 Thread Brock Wilcox
I think there are a couple answers. The simple one is yes -- embrace the whitespace. Maybe wrap them in ()', like (2 d 6). Another line of ideas is wrapping things with some other operators. Maybe a special quoting operator or a converter. [[2d6]] # double for dice! "2d6":dice # postfix. This

User defined infix operators and whitespace

2017-08-10 Thread Simon Proctor
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: ( Int $num, Int $size ) { [+] (1..$size).roll($num) }; sub prefix: ( Int $size ) { 1 d $size } Gives us 3 d 6 to roll 3 six sided dice or a prefi