Skip to content

Instantly share code, notes, and snippets.

@mdneuzerling
Created December 21, 2021 06:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdneuzerling/8d4175cd0c4bbc0498b99e1b1bc275c2 to your computer and use it in GitHub Desktop.
Save mdneuzerling/8d4175cd0c4bbc0498b99e1b1bc275c2 to your computer and use it in GitHub Desktop.
roll dice in Julia
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