💾 Archived View for gem.librehacker.com › gemlog › tech › 20210704-0.gmi captured on 2023-03-20 at 18:25:40. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2021-11-30)
-=-=-=-=-=-=-
The following bash alias prints out a number between 1 and 6, inclusive:
alias dice="guile -c '(for-each display (list (1+ (random 6 (random-state-from-platform))) #\newline))'"
Example:
christopher@nightshade ~/Repos/gemini$ dice 1 christopher@nightshade ~/Repos/gemini$ dice 2 christopher@nightshade ~/Repos/gemini$ dice 5 christopher@nightshade ~/Repos/gemini$ dice 3 christopher@nightshade ~/Repos/gemini$ dice 5 christopher@nightshade ~/Repos/gemini$ dice 6 christopher@nightshade ~/Repos/gemini$ dice 4
Cool! So I presume (being unfamiliar with guile syntax) that the 1+ is to add one to the random 6, returning 0-5?
Correct.