Elektrine lite

← Feed

@bzdev@fosstodon.org

Post #2226570

2024-12-27 02:06 UTC

@Obdurodon@hachyderm.io I have a short program called "whatyear", written in a scripting language, that prints the animal for the Chinese calendar given the western year: #!/usr/bin/scrunner -sI:year,E:true,P:true ["猴 monkey", "雞 rooster", "狗 dog", "豬 pig", "鼠 rat", "牛 ox", "虎 tiger", "兔 rabbit","龍 dragon", "蛇 snake", "馬 horse", "羊 goat" ][year %% 12] For example, ./whatyear 2024 It's a reasonable example of using Unicode characters in source code.

Replies (1)

  • @bzdev@fosstodon.org 2024-12-27 02:26

    @Obdurodon@hachyderm.io To add a bit more about the scripting language, the expression n %% m computes m mod n, and always returns a value in the range [0, m) even if n is negative: -1 %% m has the value m-1. By contrast, -1 % m would return -1.

    Open ##2226571