Jump to content

Chinese zodiac: Difference between revisions

(→‎{{header|Picat}}: Adding Picat)
(insert →‎Pascal)
Line 2,689:
2020 庚子 gēng-zĭ Metal Rat Yang 37/60
</pre>
 
=={{header|Pascal}}==
{{works with|Extended Pascal}}
The built-in functions <tt>pred</tt> and <tt>succ</tt> accepting a second (optional) parameter is an Extended Pascal (ISO 10206) extension, as well as the possibility of specifying <tt>record</tt> literals.
<lang pascal>type
animalCycle = (rat, ox, tiger, rabbit, dragon, snake,
horse, goat, monkey, rooster, dog, pig);
elementCycle = (wood, fire, earth, metal, water);
aspectCycle = (yang, yin);
zodiac = record
animal: animalCycle;
element: elementCycle;
aspect: aspectCycle;
end;
 
function getZodiac(year: integer): zodiac;
begin
year := pred(year, 4);
getZodiac := zodiac[
animal: succ(rat, year mod 12);
element: succ(wood, year mod 10 div 2);
aspect: succ(yang, year mod 2);
]
end;</lang>
 
=={{header|Perl}}==
149

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.