Actions

start:        die  /^\Z/         {$item {die}}

die:          'd' faces         {1 + int rand $item {faces}}
            | count 'd' faces   {my $s = 0;
                                  foreach (1 .. $item {count}) {
                                     $s += 1 + int rand $item {faces}
                                  }
                                  $return = $s;
                                  print "$item{count}d$item{faces} gives $s\n"}

count:        number
faces:        number
number:       /\d+/

[Prev] [Next] [Index]