Created
December 21, 2021 06:40
-
-
Save mdneuzerling/8d4175cd0c4bbc0498b99e1b1bc275c2 to your computer and use it in GitHub Desktop.
roll dice in Julia
This file contains 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 characters
macro roll(dice) | |
dice_split = split(string(dice), "d") | |
dice_split[1] = (dice_split[1] == "" ? "1" : dice_split[1]) | |
n_dice, range = parse.(Int64, dice_split) | |
:(sum(rand(1:$range, $n_dice))) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment