Chinese zodiac: Difference between revisions
Content deleted Content added
m →{{header|Phix}}: added syntax colouring, marked p2js compatible |
Added uBasic/4tH version |
||
Line 3,847: | Line 3,847: | ||
% cn_zodiac 2017 |
% cn_zodiac 2017 |
||
丁酉 ding1-you3 Fire Rooster (yin) year 34 |
丁酉 ding1-you3 Fire Rooster (yin) year 34 |
||
</pre> |
|||
=={{header|uBasic/4tH}}== |
|||
{{works with|R3}} |
|||
<lang>dim @y(2) ' yin or yang |
|||
dim @e(5) ' the elements |
|||
dim @a(12) ' the animals |
|||
Push Dup("yang"), Dup("yin") ' fill Ying/Yang table |
|||
For i = 1 to 0 step -1 : @y(i) = Pop() : Next i |
|||
' fill Elements table |
|||
Push Dup("Wood"), Dup("Fire"), Dup("Earth"), Dup("Metal"), Dup("Water") |
|||
For i = 4 to 0 step -1 : @e(i) = Pop() : Next i |
|||
' fill Animals table |
|||
Push Dup("Rat"), Dup("Ox"), Dup("Tiger"), Dup("Rabbit"), Dup("Dragon") |
|||
Push Dup("Snake"), Dup("Horse"), Dup("Goat"), Dup("Monkey"), Dup("Rooster") |
|||
Push Dup("Dog"), Dup("Pig") |
|||
For i = 11 to 0 step -1 : @a(i) = Pop() : Next i |
|||
' now push all the test yeats |
|||
Push 76543, 2186, 2020, 1984, 1861, 1801 |
|||
' and process them all |
|||
Do While Used() ' until the stack is empty |
|||
Print Show(FUNC(_Chinese(Pop()))) ' call function |
|||
Loop |
|||
End |
|||
_Chinese ' compose string |
|||
Param (1) |
|||
Local (3) |
|||
b@ = a@ % 2 |
|||
c@ = (a@ - 4) % 5 |
|||
d@ = (a@ - 4) % 12 |
|||
Return (Join(Str (a@), " is the year of the ", @e(c@), " ", @a(d@), " (", @y(b@), ").")) |
|||
</lang> |
|||
Output: |
|||
<pre> |
|||
1801 is the year of the Earth Rooster (yin). |
|||
1861 is the year of the Earth Rooster (yin). |
|||
1984 is the year of the Wood Rat (yang). |
|||
2020 is the year of the Fire Rat (yang). |
|||
2186 is the year of the Earth Dog (yang). |
|||
76543 is the year of the Water Rabbit (yin). |
|||
0 OK, 0:1047 |
|||
</pre> |
</pre> |
||