Chinese zodiac: Difference between revisions
Content added Content deleted
(→{{header|Vlang}}: Rename "Vlang" in "V (Vlang)") |
(Forth version) |
||
Line 1,811: | Line 1,811: | ||
1985 is the year of the Wood Ox (yin). |
1985 is the year of the Wood Ox (yin). |
||
2017 is the year of the Fire Rooster (yin). |
2017 is the year of the Fire Rooster (yin). |
||
</pre> |
|||
=={{header|Forth}}== |
|||
{{works with|gforth|0.7.3}} |
|||
<syntaxhighlight lang="forth"> |
|||
: position ( n -- n ) 4 - 60 mod ; |
|||
s" Rat Ox Tiger Rabbit Dragon Snake Horse Goat Monkey RoosterDog Pig " |
|||
drop constant animals |
|||
: animal ( n -- a u ) 12 mod 7 * animals + 7 -trailing ; |
|||
s" Wood Fire EarthMetalWater" drop constant elements |
|||
: element ( n -- a u ) 2/ 5 mod 5 * elements + 5 -trailing ; |
|||
s" yangyin " drop constant aspects |
|||
: aspect ( n -- a u ) 2 mod 4 * aspects + 4 -trailing ; |
|||
next-arg s>number? drop d>s position |
|||
dup element type space |
|||
dup animal type space |
|||
aspect '(' emit type ')' emit cr |
|||
bye |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
; for (x in 1935 1938 1968 1972 1976 1984 2017) {printf ''%s '' $x; gforth zodiac.f $x} |
|||
1935 Wood Pig (yin) |
|||
1938 Earth Tiger (yang) |
|||
1968 Earth Monkey (yang) |
|||
1972 Water Rat (yang) |
|||
1976 Fire Dragon (yang) |
|||
1984 Wood Rat (yang) |
|||
2017 Fire Rooster (yin) |
|||
</pre> |
</pre> |
||
=={{header|FreeBASIC}}== |
=={{header|FreeBASIC}}== |