Skip to content

Instantly share code, notes, and snippets.

@Bakudankun
Last active January 16, 2023 12:41
Show Gist options
  • Save Bakudankun/94c0cf78b501bc36ede32af2bf17ed51 to your computer and use it in GitHub Desktop.
Save Bakudankun/94c0cf78b501bc36ede32af2bf17ed51 to your computer and use it in GitHub Desktop.
:3D6 みたいに使えるサイコロ
function s:dice(count, dice) abort
const dices = map(range(a:count), {-> rand() % a:dice + 1})
echo dices
if a:count <=# 1
return
endif
echo 'sum:' reduce(dices, {acc, val -> acc + val})
endfunction
command! -range=1 -addr=other -nargs=1 -bar D call s:dice(<count>, <args>)
" vim: et sw=2 sts=-1
@Bakudankun
Copy link
Author

License: CC0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment