Dice Alias Using Guile

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

Comments

Alaskalinuxuser, 2021-07-05

Cool! So I presume (being unfamiliar with guile syntax) that the 1+ is to add one to the random 6, returning 0-5?

LibreHacker, 2021-07-05

Correct.

Proxy Information
Original URL
gemini://librehacker.com/gemlog/tech/20210704-0.gmi
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
868.810435 milliseconds
Gemini-to-HTML Time
0.304488 milliseconds

This content has been proxied by September (ba2dc).