Chinese zodiac: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
Thundergnat (talk | contribs) m (Automated syntax highlighting fixup (second round - minor fixes)) |
||
Line 24: | Line 24: | ||
Therefore 1984 was '''甲子''' (''jiă-zĭ'', or jia3-zi3). 2022 is '''壬寅''' (''rén-yín'' or ren2-yin2). |
Therefore 1984 was '''甲子''' (''jiă-zĭ'', or jia3-zi3). 2022 is '''壬寅''' (''rén-yín'' or ren2-yin2). |
||
=={{header|11l}}== |
=={{header|11l}}== |
||
{{trans|C++}} |
{{trans|C++}} |
||
<syntaxhighlight lang=11l>V animals = [‘Rat’, ‘Ox’, ‘Tiger’, ‘Rabbit’, ‘Dragon’, ‘Snake’, ‘Horse’, ‘Goat’, ‘Monkey’, ‘Rooster’, ‘Dog’, ‘Pig’] |
<syntaxhighlight lang="11l">V animals = [‘Rat’, ‘Ox’, ‘Tiger’, ‘Rabbit’, ‘Dragon’, ‘Snake’, ‘Horse’, ‘Goat’, ‘Monkey’, ‘Rooster’, ‘Dog’, ‘Pig’] |
||
V elements = [‘Wood’, ‘Fire’, ‘Earth’, ‘Metal’, ‘Water’] |
V elements = [‘Wood’, ‘Fire’, ‘Earth’, ‘Metal’, ‘Water’] |
||
Line 55: | Line 54: | ||
2017 is the year of the Fire Rooster (yin). |
2017 is the year of the Fire Rooster (yin). |
||
</pre> |
</pre> |
||
=={{header|360 Assembly}}== |
=={{header|360 Assembly}}== |
||
{{trans|VBScript}} |
{{trans|VBScript}} |
||
<syntaxhighlight lang=text>* Chinese zodiac 10/03/2019 |
<syntaxhighlight lang="text">* Chinese zodiac 10/03/2019 |
||
CHINEZOD CSECT |
CHINEZOD CSECT |
||
USING CHINEZOD,R13 base register |
USING CHINEZOD,R13 base register |
||
Line 135: | Line 133: | ||
2017 is the year of the Fire Rooster (Yin ). 34/60 |
2017 is the year of the Fire Rooster (Yin ). 34/60 |
||
</pre> |
</pre> |
||
=={{header|Action!}}== |
=={{header|Action!}}== |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="action!">DEFINE PTR="CARD" |
||
PTR ARRAY animals(12),elements(5),stems(10),branches(12),yinYangs(2) |
PTR ARRAY animals(12),elements(5),stems(10),branches(12),yinYangs(2) |
||
Line 214: | Line 211: | ||
2021 xin-chou Metal Ox Yin 38/60 |
2021 xin-chou Metal Ox Yin 38/60 |
||
</pre> |
</pre> |
||
=={{header|Ada}}== |
=={{header|Ada}}== |
||
{{works with|GNAT|8.3.0}} |
{{works with|GNAT|8.3.0}} |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="ada"> |
||
with Ada.Text_IO; use Ada.Text_IO; |
with Ada.Text_IO; use Ada.Text_IO; |
||
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; |
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; |
||
Line 348: | Line 344: | ||
2017 is the year of Fire Rooster (yin). 丁酉 |
2017 is the year of Fire Rooster (yin). 丁酉 |
||
</pre> |
</pre> |
||
=={{header|ALGOL 68}}== |
=={{header|ALGOL 68}}== |
||
{{Trans|AWK}} |
{{Trans|AWK}} |
||
<syntaxhighlight lang=algol68>BEGIN # Chinese Zodiac # |
<syntaxhighlight lang="algol68">BEGIN # Chinese Zodiac # |
||
# returns s right-padded with blanks to w characters, or s if s is already at least w characters long # |
# returns s right-padded with blanks to w characters, or s if s is already at least w characters long # |
||
PRIO PAD = 1; |
PRIO PAD = 1; |
||
Line 386: | Line 381: | ||
2017 Fire Rooster Yin |
2017 Fire Rooster Yin |
||
</pre> |
</pre> |
||
=={{header|AppleScript}}== |
=={{header|AppleScript}}== |
||
{{Trans|JavaScript}} |
{{Trans|JavaScript}} |
||
{{Trans|Haskell}} |
{{Trans|Haskell}} |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="applescript">on run |
||
-- TRADITIONAL STRINGS --------------------------------------------------- |
-- TRADITIONAL STRINGS --------------------------------------------------- |
||
Line 685: | Line 679: | ||
dīngyŏu huǒ jī yīn |
dīngyŏu huǒ jī yīn |
||
34/60 fire rooster </pre> |
34/60 fire rooster </pre> |
||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |
||
Chinese Animal/Element/Yin/Yang Characters Copied From "AppleScript" |
Chinese Animal/Element/Yin/Yang Characters Copied From "AppleScript" |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="autohotkey">Chinese_zodiac(year){ |
||
Animal := StrSplit("Rat,Ox,Tiger,Rabbit,Dragon,Snake,Horse,Goat,Monkey,Rooster,Dog,Pig", ",") |
Animal := StrSplit("Rat,Ox,Tiger,Rabbit,Dragon,Snake,Horse,Goat,Monkey,Rooster,Dog,Pig", ",") |
||
AnimalCh := StrSplit("鼠牛虎兔龍蛇馬羊猴鸡狗豬") |
AnimalCh := StrSplit("鼠牛虎兔龍蛇馬羊猴鸡狗豬") |
||
Line 715: | Line 708: | ||
return year "`t" S B " " Sn "-" Bn " `t" E " " Ec " " En "`t" A " " Ac " " An "`t" YY " " Yr |
return year "`t" S B " " Sn "-" Bn " `t" E " " Ec " " En "`t" A " " Ac " " An "`t" YY " " Yr |
||
}</syntaxhighlight> |
}</syntaxhighlight> |
||
Examples:<syntaxhighlight lang= |
Examples:<syntaxhighlight lang="autohotkey">loop 12 |
||
{ |
{ |
||
n := 1983+A_Index |
n := 1983+A_Index |
||
Line 737: | Line 730: | ||
2017 丁酉 dīng-yŏu Fire 火 huǒ Rooster 鸡 jī yīn 阴 34/60</pre> |
2017 丁酉 dīng-yŏu Fire 火 huǒ Rooster 鸡 jī yīn 阴 34/60</pre> |
||
=={{header|AWK}}== |
=={{header|AWK}}== |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="awk"> |
||
# syntax: GAWK -f CHINESE_ZODIAC.AWK |
# syntax: GAWK -f CHINESE_ZODIAC.AWK |
||
BEGIN { |
BEGIN { |
||
Line 768: | Line 760: | ||
2017 Fire Rooster Yin |
2017 Fire Rooster Yin |
||
</pre> |
</pre> |
||
=={{header|BASIC256}}== |
=={{header|BASIC256}}== |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="basic256"> |
||
# Chinese zodiac |
# Chinese zodiac |
||
Line 806: | Line 797: | ||
2017: 丁酉 (dīng-yŏu, Fire Rooster; Yin - ciclo 34/60) |
2017: 丁酉 (dīng-yŏu, Fire Rooster; Yin - ciclo 34/60) |
||
</pre> |
</pre> |
||
=={{header|Befunge}}== |
=={{header|Befunge}}== |
||
<syntaxhighlight lang=befunge>0" :raeY">:#,_55+"< /8"&>+:66+%00p:55+v |
<syntaxhighlight lang="befunge">0" :raeY">:#,_55+"< /8"&>+:66+%00p:55+v |
||
v"Aspect: "0++88*5%2\0\+1%"<":p01++66/2%< |
v"Aspect: "0++88*5%2\0\+1%"<":p01++66/2%< |
||
>00g5g7-0" :laminA"10g5g"<"+0" :tnemelE"v |
>00g5g7-0" :laminA"10g5g"<"+0" :tnemelE"v |
||
Line 825: | Line 815: | ||
Aspect: yang |
Aspect: yang |
||
Cycle: 35 / 60</pre> |
Cycle: 35 / 60</pre> |
||
=={{header|C}}== |
=={{header|C}}== |
||
{{trans|C++}} |
{{trans|C++}} |
||
<syntaxhighlight lang=c>#include <math.h> |
<syntaxhighlight lang="c">#include <math.h> |
||
#include <stdio.h> |
#include <stdio.h> |
||
Line 870: | Line 859: | ||
1976 is the year of the Fire Dragon (yang). |
1976 is the year of the Fire Dragon (yang). |
||
2017 is the year of the Fire Rooster (yin).</pre> |
2017 is the year of the Fire Rooster (yin).</pre> |
||
=={{header|C sharp|C#}}== |
=={{header|C sharp|C#}}== |
||
{{trans|Java}} |
{{trans|Java}} |
||
<syntaxhighlight lang=csharp>using System; |
<syntaxhighlight lang="csharp">using System; |
||
namespace ChineseZodiac { |
namespace ChineseZodiac { |
||
Line 909: | Line 897: | ||
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). 丁酉</pre> |
2017 is the year of the Fire Rooster (yin). 丁酉</pre> |
||
=={{header|C++}}== |
=={{header|C++}}== |
||
<syntaxhighlight lang=cpp>#include <iostream> |
<syntaxhighlight lang="cpp">#include <iostream> |
||
#include <cmath> |
#include <cmath> |
||
Line 961: | Line 948: | ||
2017 is the year of the Fire Rooster (yin). |
2017 is the year of the Fire Rooster (yin). |
||
</pre> |
</pre> |
||
=={{header|Clojure}}== |
=={{header|Clojure}}== |
||
<syntaxhighlight lang=clojure>(def base-year 4) |
<syntaxhighlight lang="clojure">(def base-year 4) |
||
(def celestial-stems ["甲" "乙" "丙" "丁" "戊" "己" "庚" "辛" "壬" "癸"]) |
(def celestial-stems ["甲" "乙" "丙" "丁" "戊" "己" "庚" "辛" "壬" "癸"]) |
||
(def terrestrial-branches ["子" "丑" "寅" "卯" "辰" "巳" "午" "未" "申" "酉" "戌" "亥"]) |
(def terrestrial-branches ["子" "丑" "寅" "卯" "辰" "巳" "午" "未" "申" "酉" "戌" "亥"]) |
||
Line 1,005: | Line 991: | ||
2017: 丁酉 (dīng-yŏu, Fire Rooster; yin - cycle 34/60) |
2017: 丁酉 (dīng-yŏu, Fire Rooster; yin - cycle 34/60) |
||
</pre> |
</pre> |
||
=={{header|Commodore BASIC}}== |
=={{header|Commodore BASIC}}== |
||
{{works with|Commodore 64/128}} |
{{works with|Commodore 64/128}} |
||
<syntaxhighlight lang=basic>1000 rem display the chinese zodiac for a given year |
<syntaxhighlight lang="basic">1000 rem display the chinese zodiac for a given year |
||
1010 poke 53281,7: rem yellow background |
1010 poke 53281,7: rem yellow background |
||
1020 poke 53280,2: rem red border |
1020 poke 53280,2: rem red border |
||
Line 1,081: | Line 1,066: | ||
{{Out}} |
{{Out}} |
||
https://i.imgur.com/f3Fo1xm.png |
https://i.imgur.com/f3Fo1xm.png |
||
=={{header|Common Lisp}}== |
=={{header|Common Lisp}}== |
||
{{trans|Ruby}} |
{{trans|Ruby}} |
||
<syntaxhighlight lang=lisp>; Any CE Year that was the first of a 60-year cycle |
<syntaxhighlight lang="lisp">; Any CE Year that was the first of a 60-year cycle |
||
(defconstant base-year 1984) |
(defconstant base-year 1984) |
||
Line 1,153: | Line 1,137: | ||
1976: 丙辰 (bĭng-chén, Fire Dragon; yang) |
1976: 丙辰 (bĭng-chén, Fire Dragon; yang) |
||
</pre> |
</pre> |
||
=={{header|D}}== |
=={{header|D}}== |
||
{{trans|haskell}} |
{{trans|haskell}} |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="d">import std.stdio; |
||
// 10 heavenly stems |
// 10 heavenly stems |
||
Line 1,248: | Line 1,231: | ||
{{libheader| System.Math}} |
{{libheader| System.Math}} |
||
{{Trans|C#}} |
{{Trans|C#}} |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="delphi"> |
||
program Chinese_zodiac; |
program Chinese_zodiac; |
||
Line 1,347: | Line 1,330: | ||
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). 丁酉</pre> |
2017 is the year of the Fire Rooster (yin). 丁酉</pre> |
||
=={{header|Excel}}== |
=={{header|Excel}}== |
||
===LAMBDA=== |
===LAMBDA=== |
||
Line 1,356: | Line 1,338: | ||
{{Works with|Office 365 betas 2021}} |
{{Works with|Office 365 betas 2021}} |
||
<syntaxhighlight lang=lisp>CNZODIAC |
<syntaxhighlight lang="lisp">CNZODIAC |
||
=LAMBDA(y, |
=LAMBDA(y, |
||
APPENDCOLS( |
APPENDCOLS( |
||
Line 1,499: | Line 1,481: | ||
and also assuming the following generic bindings in the Name Manager for the WorkBook: |
and also assuming the following generic bindings in the Name Manager for the WorkBook: |
||
<syntaxhighlight lang=lisp>APPENDCOLS |
<syntaxhighlight lang="lisp">APPENDCOLS |
||
=LAMBDA(xs, |
=LAMBDA(xs, |
||
LAMBDA(ys, |
LAMBDA(ys, |
||
Line 1,752: | Line 1,734: | ||
| style="text-align:center" | bright |
| style="text-align:center" | bright |
||
|} |
|} |
||
=={{header|F Sharp|F#}}== |
=={{header|F Sharp|F#}}== |
||
<syntaxhighlight lang=fsharp> |
<syntaxhighlight lang="fsharp"> |
||
open System |
open System |
||
Line 1,788: | Line 1,769: | ||
2017 is the year of the Fire Rooster (Yin) |
2017 is the year of the Fire Rooster (Yin) |
||
</pre> |
</pre> |
||
=={{header|Factor}}== |
=={{header|Factor}}== |
||
<syntaxhighlight lang=factor>USING: circular formatting io kernel math qw sequences |
<syntaxhighlight lang="factor">USING: circular formatting io kernel math qw sequences |
||
sequences.repeating ; |
sequences.repeating ; |
||
IN: rosetta-code.zodiac |
IN: rosetta-code.zodiac |
||
Line 1,832: | Line 1,812: | ||
2017 is the year of the Fire Rooster (yin). |
2017 is the year of the Fire Rooster (yin). |
||
</pre> |
</pre> |
||
=={{header|FreeBASIC}}== |
=={{header|FreeBASIC}}== |
||
<syntaxhighlight lang=freebasic>dim as string yy(0 to 1) = {"yang", "yin"} |
<syntaxhighlight lang="freebasic">dim as string yy(0 to 1) = {"yang", "yin"} |
||
dim as string elements(0 to 4) = {"Wood", "Fire", "Earth", "Metal", "Water"} |
dim as string elements(0 to 4) = {"Wood", "Fire", "Earth", "Metal", "Water"} |
||
dim as string animals(0 to 11) = {"Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snake",_ |
dim as string animals(0 to 11) = {"Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snake",_ |
||
Line 1,860: | Line 1,839: | ||
2186 is the year of the Earth Dog (yang). |
2186 is the year of the Earth Dog (yang). |
||
76543 is the year of the Water Rabbit (yin).</pre> |
76543 is the year of the Water Rabbit (yin).</pre> |
||
=={{header|Fōrmulæ}}== |
=={{header|Fōrmulæ}}== |
||
Line 1,868: | Line 1,846: | ||
In '''[https://formulae.org/?example=Chinese_zodiac this]''' page you can see the program(s) related to this task and their results. |
In '''[https://formulae.org/?example=Chinese_zodiac this]''' page you can see the program(s) related to this task and their results. |
||
=={{header|Go}}== |
=={{header|Go}}== |
||
<syntaxhighlight lang=go>package main |
<syntaxhighlight lang="go">package main |
||
import "fmt" |
import "fmt" |
||
Line 1,909: | Line 1,886: | ||
1976: Fire Dragon, Yang, Cycle year 53 丙辰 |
1976: Fire Dragon, Yang, Cycle year 53 丙辰 |
||
</pre> |
</pre> |
||
=={{header|Groovy}}== |
=={{header|Groovy}}== |
||
{{trans|Java}} |
{{trans|Java}} |
||
<syntaxhighlight lang=groovy>class Zodiac { |
<syntaxhighlight lang="groovy">class Zodiac { |
||
final static String[] animals = ["Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snake", "Horse", "Goat", "Monkey", "Rooster", "Dog", "Pig"] |
final static String[] animals = ["Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snake", "Horse", "Goat", "Monkey", "Rooster", "Dog", "Pig"] |
||
final static String[] elements = ["Wood", "Fire", "Earth", "Metal", "Water"] |
final static String[] elements = ["Wood", "Fire", "Earth", "Metal", "Water"] |
||
Line 1,942: | Line 1,918: | ||
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). 丁酉</pre> |
2017 is the year of the Fire Rooster (yin). 丁酉</pre> |
||
=={{header|Haskell}}== |
=={{header|Haskell}}== |
||
(We can use Chinese characters in Haskell names, as long as the first character is lower-case alphabetic) |
(We can use Chinese characters in Haskell names, as long as the first character is lower-case alphabetic) |
||
<syntaxhighlight lang=haskell>import Data.Array (Array, listArray, (!)) |
<syntaxhighlight lang="haskell">import Data.Array (Array, listArray, (!)) |
||
------------------- TRADITIONAL STRINGS ------------------ |
------------------- TRADITIONAL STRINGS ------------------ |
||
Line 2,077: | Line 2,052: | ||
dīngyŏu huǒ jī yīn |
dīngyŏu huǒ jī yīn |
||
34/60 fire rooster </pre> |
34/60 fire rooster </pre> |
||
=={{header|J}}== |
=={{header|J}}== |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="j"> ELEMENTS=: _4 |. 2 # ;:'Wood Fire Earth Metal Water' |
||
YEARS=: 1935 1938 1968 1972 1976 2017 |
YEARS=: 1935 1938 1968 1972 1976 2017 |
||
Line 2,121: | Line 2,095: | ||
2017 丁 酉 ( yin ) |
2017 丁 酉 ( yin ) |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
=={{header|Java}}== |
=={{header|Java}}== |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="java">public class Zodiac { |
||
final static String animals[]={"Rat","Ox","Tiger","Rabbit","Dragon","Snake","Horse","Goat","Monkey","Rooster","Dog","Pig"}; |
final static String animals[]={"Rat","Ox","Tiger","Rabbit","Dragon","Snake","Horse","Goat","Monkey","Rooster","Dog","Pig"}; |
||
Line 2,163: | Line 2,136: | ||
2017 is the year of the Fire Rooster (yin). 丁酉 |
2017 is the year of the Fire Rooster (yin). 丁酉 |
||
</pre> |
</pre> |
||
=={{header|JavaScript}}== |
=={{header|JavaScript}}== |
||
===ES6=== |
===ES6=== |
||
{{Trans|Haskell}} |
{{Trans|Haskell}} |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="javascript">(() => { |
||
"use strict"; |
"use strict"; |
||
Line 2,383: | Line 2,355: | ||
rényín shuǐ hǔ yáng |
rényín shuǐ hǔ yáng |
||
39/60 water tiger </pre> |
39/60 water tiger </pre> |
||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
{{works with|Julia|0.6}} |
{{works with|Julia|0.6}} |
||
{{trans|Python}} |
{{trans|Python}} |
||
<syntaxhighlight lang=julia>function chinese(year::Int) |
<syntaxhighlight lang="julia">function chinese(year::Int) |
||
pinyin = Dict( |
pinyin = Dict( |
||
"甲" => "jiă", |
"甲" => "jiă", |
||
Line 2,454: | Line 2,425: | ||
1976: 丙辰 (bĭng-chén, Fire Dragon; yang - year 53 of the cycle) |
1976: 丙辰 (bĭng-chén, Fire Dragon; yang - year 53 of the cycle) |
||
2018: 戊戌 (wù-xū, Earth Dog; yang - year 35 of the cycle)</pre> |
2018: 戊戌 (wù-xū, Earth Dog; yang - year 35 of the cycle)</pre> |
||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |
||
<syntaxhighlight lang=scala>// version 1.1.2 |
<syntaxhighlight lang="scala">// version 1.1.2 |
||
class ChineseZodiac(val year: Int) { |
class ChineseZodiac(val year: Int) { |
||
Line 2,517: | Line 2,487: | ||
2017 丁酉 dīng-yŏu Fire Rooster Yin 34/60 |
2017 丁酉 dīng-yŏu Fire Rooster Yin 34/60 |
||
</pre> |
</pre> |
||
=={{header|Lua}}== |
=={{header|Lua}}== |
||
{{trans|C}} |
{{trans|C}} |
||
<syntaxhighlight lang=lua>local ANIMALS = {"Rat","Ox","Tiger","Rabbit","Dragon","Snake","Horse","Goat","Monkey","Rooster","Dog","Pig"} |
<syntaxhighlight lang="lua">local ANIMALS = {"Rat","Ox","Tiger","Rabbit","Dragon","Snake","Horse","Goat","Monkey","Rooster","Dog","Pig"} |
||
local ELEMENTS = {"Wood","Fire","Earth","Metal","Water"} |
local ELEMENTS = {"Wood","Fire","Earth","Metal","Water"} |
||
Line 2,561: | Line 2,530: | ||
1976 is the year of the Fire Dragon (yang) |
1976 is the year of the Fire Dragon (yang) |
||
2017 is the year of the Fire Rooster (yin)</pre> |
2017 is the year of the Fire Rooster (yin)</pre> |
||
=={{header|Maple}}== |
=={{header|Maple}}== |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="maple"> |
||
zodiac:=proc(year::integer) |
zodiac:=proc(year::integer) |
||
local year60,yinyang,animal,element; |
local year60,yinyang,animal,element; |
||
Line 2,573: | Line 2,541: | ||
end proc: |
end proc: |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
=={{header|Mathematica}} / {{header|Wolfram Language}}== |
=={{header|Mathematica}} / {{header|Wolfram Language}}== |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="mathematica">pinyin = <|"甲" -> "jiă", "乙" -> "yĭ", "丙" -> "bĭng", "丁" -> "dīng", |
||
"戊" -> "wù", "己" -> "jĭ", "庚" -> "gēng", "辛" -> "xīn", |
"戊" -> "wù", "己" -> "jĭ", "庚" -> "gēng", "辛" -> "xīn", |
||
"壬" -> "rén", "癸" -> "gŭi", "子" -> "zĭ", "丑" -> "chŏu", |
"壬" -> "rén", "癸" -> "gŭi", "子" -> "zĭ", "丑" -> "chŏu", |
||
Line 2,622: | Line 2,589: | ||
1972: 壬子 (rén-zĭ, Water Rat; yang) |
1972: 壬子 (rén-zĭ, Water Rat; yang) |
||
1976: 丙辰 (bĭng-chén, Fire Dragon; yang)</pre> |
1976: 丙辰 (bĭng-chén, Fire Dragon; yang)</pre> |
||
=={{header|Modula-2}}== |
=={{header|Modula-2}}== |
||
{{trans|C++}} |
{{trans|C++}} |
||
<syntaxhighlight lang=modula2>MODULE ChineseZodiac; |
<syntaxhighlight lang="modula2">MODULE ChineseZodiac; |
||
FROM FormatString IMPORT FormatString; |
FROM FormatString IMPORT FormatString; |
||
FROM Terminal IMPORT WriteString,ReadChar; |
FROM Terminal IMPORT WriteString,ReadChar; |
||
Line 2,678: | Line 2,644: | ||
ReadChar |
ReadChar |
||
END ChineseZodiac.</syntaxhighlight> |
END ChineseZodiac.</syntaxhighlight> |
||
=={{header|Nim}}== |
=={{header|Nim}}== |
||
{{trans|Rust}} |
{{trans|Rust}} |
||
<syntaxhighlight lang=nim>import strformat |
<syntaxhighlight lang="nim">import strformat |
||
const ANIMALS: array[12, string] = ["Rat", "Ox", |
const ANIMALS: array[12, string] = ["Rat", "Ox", |
||
Line 2,740: | Line 2,705: | ||
2020 庚子 gēng-zĭ Metal Rat Yang 37/60 |
2020 庚子 gēng-zĭ Metal Rat Yang 37/60 |
||
</pre> |
</pre> |
||
=={{header|Pascal}}== |
=={{header|Pascal}}== |
||
{{works with|Extended 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. |
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. |
||
<syntaxhighlight lang=pascal>type |
<syntaxhighlight lang="pascal">type |
||
animalCycle = (rat, ox, tiger, rabbit, dragon, snake, |
animalCycle = (rat, ox, tiger, rabbit, dragon, snake, |
||
horse, goat, monkey, rooster, dog, pig); |
horse, goat, monkey, rooster, dog, pig); |
||
Line 2,765: | Line 2,729: | ||
] |
] |
||
end;</syntaxhighlight> |
end;</syntaxhighlight> |
||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
<syntaxhighlight lang=perl>sub zodiac { |
<syntaxhighlight lang="perl">sub zodiac { |
||
my $year = shift; |
my $year = shift; |
||
my @animals = qw/Rat Ox Tiger Rabbit Dragon Snake Horse Goat Monkey Rooster Dog Pig/; |
my @animals = qw/Rat Ox Tiger Rabbit Dragon Snake Horse Goat Monkey Rooster Dog Pig/; |
||
Line 2,797: | Line 2,760: | ||
2017: 丁酉 (dīng-yŏu) Fire Rooster; yin - year 34 of the cycle |
2017: 丁酉 (dīng-yŏu) Fire Rooster; yin - year 34 of the cycle |
||
</pre> |
</pre> |
||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
<!--<syntaxhighlight lang= |
<!--<syntaxhighlight lang="phix">(phixonline)--> |
||
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span> |
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span> |
||
<span style="color: #008080;">constant</span> <span style="color: #000000;">animals</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #008000;">"Rat"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Ox"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Tiger"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Rabbit"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Dragon"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Snake"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Horse"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Goat"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Monkey"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Rooster"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Dog"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Pig"</span><span style="color: #0000FF;">},</span> |
<span style="color: #008080;">constant</span> <span style="color: #000000;">animals</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #008000;">"Rat"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Ox"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Tiger"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Rabbit"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Dragon"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Snake"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Horse"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Goat"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Monkey"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Rooster"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Dog"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Pig"</span><span style="color: #0000FF;">},</span> |
||
Line 2,825: | Line 2,787: | ||
2018: Earth Dog; yang, year 35 of the cycle. |
2018: Earth Dog; yang, year 35 of the cycle. |
||
</pre> |
</pre> |
||
=={{header|Picat}}== |
=={{header|Picat}}== |
||
{{trans|Prolog}} |
{{trans|Prolog}} |
||
{{works with|Picat}} |
{{works with|Picat}} |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="picat"> |
||
animals({"Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snake", "Horse", "Goat", "Monkey", "Rooster", "Dog", "Pig"}). |
animals({"Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snake", "Horse", "Goat", "Monkey", "Rooster", "Dog", "Pig"}). |
||
Line 2,887: | Line 2,848: | ||
2017 is the year of the Fire Rooster (yin). 丁酉 |
2017 is the year of the Fire Rooster (yin). 丁酉 |
||
</pre> |
</pre> |
||
=={{header|PowerShell}}== |
=={{header|PowerShell}}== |
||
{{trans|Ruby}} |
{{trans|Ruby}} |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="powershell"> |
||
function Get-ChineseZodiac |
function Get-ChineseZodiac |
||
{ |
{ |
||
Line 2,977: | Line 2,937: | ||
} |
} |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="powershell"> |
||
1935, 1938, 1968, 1972, 1976 | Get-ChineseZodiac | Format-Table |
1935, 1938, 1968, 1972, 1976 | Get-ChineseZodiac | Format-Table |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
Line 2,991: | Line 2,951: | ||
</pre> |
</pre> |
||
Defaults to the current year: |
Defaults to the current year: |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="powershell"> |
||
Get-ChineseZodiac |
Get-ChineseZodiac |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
Line 3,005: | Line 2,965: | ||
</pre> |
</pre> |
||
Using the '''Year''' property of a <code>[DateTime]</code> object: |
Using the '''Year''' property of a <code>[DateTime]</code> object: |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="powershell"> |
||
Get-Date "11/8/2016" | Get-ChineseZodiac |
Get-Date "11/8/2016" | Get-ChineseZodiac |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
Line 3,019: | Line 2,979: | ||
</pre> |
</pre> |
||
Emulate the Ruby script's output: |
Emulate the Ruby script's output: |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="powershell"> |
||
$zodiacs = 1935, 1938, 1968, 1972, 1976 | Get-ChineseZodiac |
$zodiacs = 1935, 1938, 1968, 1972, 1976 | Get-ChineseZodiac |
||
Line 3,041: | Line 3,001: | ||
1976: 丙辰 (bĭng-chén, Fire Dragon; yang - year 53 of the cycle) |
1976: 丙辰 (bĭng-chén, Fire Dragon; yang - year 53 of the cycle) |
||
</pre> |
</pre> |
||
=={{header|Prolog}}== |
=={{header|Prolog}}== |
||
{{trans|Java}} |
{{trans|Java}} |
||
{{works with|GNU Prolog}} |
{{works with|GNU Prolog}} |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="prolog"> |
||
:- initialization(main). |
:- initialization(main). |
||
Line 3,116: | Line 3,075: | ||
2017 is the year of the Fire Rooster (yin). 丁酉 |
2017 is the year of the Fire Rooster (yin). 丁酉 |
||
</pre> |
</pre> |
||
=={{header|PureBasic}}== |
=={{header|PureBasic}}== |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="purebasic">EnableExplicit |
||
#BASE=4 |
#BASE=4 |
||
#SPC=Chr(32) |
#SPC=Chr(32) |
||
Line 3,179: | Line 3,137: | ||
1984 Wood Rat yang 1 jiă-zĭ 甲子 |
1984 Wood Rat yang 1 jiă-zĭ 甲子 |
||
2017 Fire Rooster yin 34 dīng-yŏu 丁酉</pre> |
2017 Fire Rooster yin 34 dīng-yŏu 丁酉</pre> |
||
=={{header|Python}}== |
=={{header|Python}}== |
||
{{trans|Ruby}} |
{{trans|Ruby}} |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="python"> |
||
# coding: utf-8 |
# coding: utf-8 |
||
Line 3,252: | Line 3,209: | ||
Or, segmenting tokens just in time, and writing out wiki tables: |
Or, segmenting tokens just in time, and writing out wiki tables: |
||
{{Works with|Python|3.7}} |
{{Works with|Python|3.7}} |
||
<syntaxhighlight lang=python>'''Chinese zodiac''' |
<syntaxhighlight lang="python">'''Chinese zodiac''' |
||
from functools import (reduce) |
from functools import (reduce) |
||
Line 3,556: | Line 3,513: | ||
|dark |
|dark |
||
|} |
|} |
||
=={{header|Racket}}== |
=={{header|Racket}}== |
||
{{trans|Common Lisp}} |
{{trans|Common Lisp}} |
||
<syntaxhighlight lang=racket>#lang racket |
<syntaxhighlight lang="racket">#lang racket |
||
(require racket/date) |
(require racket/date) |
||
Line 3,615: | Line 3,571: | ||
1972: 壬子 (rén-zĭ, Water Rat; yang) |
1972: 壬子 (rén-zĭ, Water Rat; yang) |
||
1976: 丙辰 (bĭng-chén, Fire Dragon; yang)</pre> |
1976: 丙辰 (bĭng-chén, Fire Dragon; yang)</pre> |
||
=={{header|Raku}}== |
=={{header|Raku}}== |
||
(formerly Perl 6) |
(formerly Perl 6) |
||
Line 3,621: | Line 3,576: | ||
{{trans|Ruby}} |
{{trans|Ruby}} |
||
<syntaxhighlight lang=raku line>sub Chinese-zodiac ( Int $year ) { |
<syntaxhighlight lang="raku" line>sub Chinese-zodiac ( Int $year ) { |
||
my @heaven = <甲 jiă 乙 yĭ 丙 bĭng 丁 dīng 戊 wù 己 jĭ 庚 gēng 辛 xīn 壬 rén 癸 gŭi>.pairup; |
my @heaven = <甲 jiă 乙 yĭ 丙 bĭng 丁 dīng 戊 wù 己 jĭ 庚 gēng 辛 xīn 壬 rén 癸 gŭi>.pairup; |
||
my @earth = <子 zĭ 丑 chŏu 寅 yín 卯 măo 辰 chén 巳 sì 午 wŭ 未 wèi 申 shēn 酉 yŏu 戌 xū 亥 hài>.pairup; |
my @earth = <子 zĭ 丑 chŏu 寅 yín 卯 măo 辰 chén 巳 sì 午 wŭ 未 wèi 申 shēn 酉 yŏu 戌 xū 亥 hài>.pairup; |
||
Line 3,658: | Line 3,613: | ||
1984: 甲子 (jiăzĭ, Wood Rat; yang - year 1 in the cycle) |
1984: 甲子 (jiăzĭ, Wood Rat; yang - year 1 in the cycle) |
||
2017: 丁酉 (dīngyŏu, Fire Rooster; yin - year 34 in the cycle)</pre> |
2017: 丁酉 (dīngyŏu, Fire Rooster; yin - year 34 in the cycle)</pre> |
||
=={{header|Ring}}== |
=={{header|Ring}}== |
||
<syntaxhighlight lang=ring> |
<syntaxhighlight lang="ring"> |
||
yinyang = ["yang", "yin"] |
yinyang = ["yang", "yin"] |
||
elements = ["Wood", "Fire", "Earth", "Metal", "Water"] |
elements = ["Wood", "Fire", "Earth", "Metal", "Water"] |
||
Line 3,686: | Line 3,640: | ||
76543 is the year of the Water Rabbit (yin). |
76543 is the year of the Water Rabbit (yin). |
||
</pre> |
</pre> |
||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
This is written as a command-line tool that takes a list of CE year numbers as arguments and outputs their information; if no arguments are supplied, it displays the information for the current year. |
This is written as a command-line tool that takes a list of CE year numbers as arguments and outputs their information; if no arguments are supplied, it displays the information for the current year. |
||
<syntaxhighlight lang=ruby># encoding: utf-8 |
<syntaxhighlight lang="ruby"># encoding: utf-8 |
||
pinyin = { |
pinyin = { |
||
'甲' => 'jiă', |
'甲' => 'jiă', |
||
Line 3,767: | Line 3,720: | ||
Given no arguments and run during the year 2017: |
Given no arguments and run during the year 2017: |
||
<pre>丁酉 (dīng-yŏu, Fire Rooster; yin - year 34 of the cycle)</pre> |
<pre>丁酉 (dīng-yŏu, Fire Rooster; yin - year 34 of the cycle)</pre> |
||
=={{header|Rust}}== |
=={{header|Rust}}== |
||
{{trans|Kotlin}} |
{{trans|Kotlin}} |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="rust">fn chinese_zodiac(year: usize) -> String { |
||
static ANIMALS: [&str; 12] = [ |
static ANIMALS: [&str; 12] = [ |
||
"Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snake", |
"Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snake", |
||
Line 3,835: | Line 3,787: | ||
1984 甲子 jiă-zĭ Wood Rat Yang 01/60 |
1984 甲子 jiă-zĭ Wood Rat Yang 01/60 |
||
2017 丁酉 dīng-yŏu Fire Rooster Yin 34/60</pre> |
2017 丁酉 dīng-yŏu Fire Rooster Yin 34/60</pre> |
||
=={{header|Scala}}== |
=={{header|Scala}}== |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="scala">object Zodiac extends App { |
||
val years = Seq(1935, 1938, 1968, 1972, 1976, 1984, 1985, 2017, 2018) |
val years = Seq(1935, 1938, 1968, 1972, 1976, 1984, 1985, 2017, 2018) |
||
Line 3,874: | Line 3,825: | ||
}</syntaxhighlight> |
}</syntaxhighlight> |
||
{{Out}}See it in running in your browser by [https://scalafiddle.io/sf/O6MUr27/0 ScalaFiddle (JavaScript)] or by [https://scastie.scala-lang.org/KXC0j71ORFaQxNZSCCZ1Aw Scastie (JVM)]. |
{{Out}}See it in running in your browser by [https://scalafiddle.io/sf/O6MUr27/0 ScalaFiddle (JavaScript)] or by [https://scastie.scala-lang.org/KXC0j71ORFaQxNZSCCZ1Aw Scastie (JVM)]. |
||
=={{header|Seed7}}== |
=={{header|Seed7}}== |
||
The standard output file of Seed7 accepts only Latin-1 (byte) output. |
The standard output file of Seed7 accepts only Latin-1 (byte) output. |
||
Line 3,881: | Line 3,831: | ||
The library [http://seed7.sourceforge.net/libraries/console.htm console.s7i] defines STD_CONSOLE. |
The library [http://seed7.sourceforge.net/libraries/console.htm console.s7i] defines STD_CONSOLE. |
||
<syntaxhighlight lang=seed7>$ include "seed7_05.s7i"; |
<syntaxhighlight lang="seed7">$ include "seed7_05.s7i"; |
||
include "console.s7i"; |
include "console.s7i"; |
||
Line 3,915: | Line 3,865: | ||
2017 is the year of the Fire Rooster (yin). 丁酉 |
2017 is the year of the Fire Rooster (yin). 丁酉 |
||
</pre> |
</pre> |
||
=={{header|Sidef}}== |
=={{header|Sidef}}== |
||
{{trans|Perl}} |
{{trans|Perl}} |
||
<syntaxhighlight lang=ruby>func zodiac(year) { |
<syntaxhighlight lang="ruby">func zodiac(year) { |
||
var animals = %w(Rat Ox Tiger Rabbit Dragon Snake Horse Goat Monkey Rooster Dog Pig) |
var animals = %w(Rat Ox Tiger Rabbit Dragon Snake Horse Goat Monkey Rooster Dog Pig) |
||
var elements = %w(Wood Fire Earth Metal Water) |
var elements = %w(Wood Fire Earth Metal Water) |
||
Line 3,948: | Line 3,897: | ||
2017: 丁酉 (dīng-yŏu) Fire Rooster; yin - year 34 of the cycle |
2017: 丁酉 (dīng-yŏu) Fire Rooster; yin - year 34 of the cycle |
||
</pre> |
</pre> |
||
=={{header|tbas}}== |
=={{header|tbas}}== |
||
<syntaxhighlight lang=qbasic> |
<syntaxhighlight lang="qbasic"> |
||
DATA "甲","乙","丙","丁","戊","己","庚","辛","壬","癸" |
DATA "甲","乙","丙","丁","戊","己","庚","辛","壬","癸" |
||
DECLARE celestial$(10) |
DECLARE celestial$(10) |
||
Line 4,035: | Line 3,983: | ||
</pre> |
</pre> |
||
=={{header|Tcl}}== |
=={{header|Tcl}}== |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="tcl"> |
||
proc cn_zodiac year { |
proc cn_zodiac year { |
||
set year0 [expr $year-4] |
set year0 [expr $year-4] |
||
Line 4,061: | Line 4,008: | ||
丁酉 ding1-you3 Fire Rooster (yin) year 34 |
丁酉 ding1-you3 Fire Rooster (yin) year 34 |
||
</pre> |
</pre> |
||
=={{header|uBasic/4tH}}== |
=={{header|uBasic/4tH}}== |
||
{{works with|R3}} |
{{works with|R3}} |
||
<syntaxhighlight lang=text>dim @y(2) ' yin or yang |
<syntaxhighlight lang="text">dim @y(2) ' yin or yang |
||
dim @e(5) ' the elements |
dim @e(5) ' the elements |
||
dim @a(12) ' the animals |
dim @a(12) ' the animals |
||
Line 4,108: | Line 4,054: | ||
0 OK, 0:1047 |
0 OK, 0:1047 |
||
</pre> |
</pre> |
||
=={{header|UNIX Shell}}== |
=={{header|UNIX Shell}}== |
||
{{works with|Bash|4+}} |
{{works with|Bash|4+}} |
||
Line 4,269: | Line 4,214: | ||
1972:壬子(rén-zĭ, Water Rat; yang) |
1972:壬子(rén-zĭ, Water Rat; yang) |
||
1976:丙辰(bĭng-chén, Fire Dragon; yang)</pre> |
1976:丙辰(bĭng-chén, Fire Dragon; yang)</pre> |
||
=={{header|UTFool}}== |
=={{header|UTFool}}== |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="utfool"> |
||
··· |
··· |
||
http://rosettacode.org/wiki/Chinese_zodiac |
http://rosettacode.org/wiki/Chinese_zodiac |
||
Line 4,313: | Line 4,257: | ||
wuxing[2][stem / 2], shengxiao[2][branch] |
wuxing[2][stem / 2], shengxiao[2][branch] |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
=={{header|VBScript}}== |
=={{header|VBScript}}== |
||
To run in console mode with cscript. |
To run in console mode with cscript. |
||
<syntaxhighlight lang=vb>' Chinese zodiac - VBS |
<syntaxhighlight lang="vb">' Chinese zodiac - VBS |
||
Animals = array( "Rat","Ox","Tiger","Rabbit","Dragon","Snake","Horse","Goat","Monkey","Rooster","Dog","Pig" ) |
Animals = array( "Rat","Ox","Tiger","Rabbit","Dragon","Snake","Horse","Goat","Monkey","Rooster","Dog","Pig" ) |
||
Line 4,342: | Line 4,285: | ||
2017 is the year of the Fire Rooster (Yin). |
2017 is the year of the Fire Rooster (Yin). |
||
</pre> |
</pre> |
||
=={{header|Visual Basic .NET}}== |
=={{header|Visual Basic .NET}}== |
||
{{trans|C#}} |
{{trans|C#}} |
||
<syntaxhighlight lang=vbnet>Module Module1 |
<syntaxhighlight lang="vbnet">Module Module1 |
||
ReadOnly ANIMALS As String() = {"Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snake", "Horse", "Goat", "Monkey", "Rooster", "Dog", "Pig"} |
ReadOnly ANIMALS As String() = {"Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snake", "Horse", "Goat", "Monkey", "Rooster", "Dog", "Pig"} |
||
Line 4,385: | Line 4,327: | ||
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). 丁酉</pre> |
2017 is the year of the Fire Rooster (yin). 丁酉</pre> |
||
=={{header|Vlang}}== |
=={{header|Vlang}}== |
||
{{trans|Go}} |
{{trans|Go}} |
||
<syntaxhighlight lang=vlang>const ( |
<syntaxhighlight lang="vlang">const ( |
||
animal_string = ["Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snake", |
animal_string = ["Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snake", |
||
"Horse", "Goat", "Monkey", "Rooster", "Dog", "Pig"] |
"Horse", "Goat", "Monkey", "Rooster", "Dog", "Pig"] |
||
Line 4,419: | Line 4,360: | ||
Same as Go entry |
Same as Go entry |
||
</pre> |
</pre> |
||
=={{header|Wren}}== |
=={{header|Wren}}== |
||
{{trans|Kotlin}} |
{{trans|Kotlin}} |
||
{{libheader|Wren-fmt}} |
{{libheader|Wren-fmt}} |
||
<syntaxhighlight lang=ecmascript>import "/fmt" for Fmt |
<syntaxhighlight lang="ecmascript">import "/fmt" for Fmt |
||
class ChineseZodiac { |
class ChineseZodiac { |
||
Line 4,481: | Line 4,421: | ||
2020 庚子 gēng-zĭ Metal Rat Yang 37/60 |
2020 庚子 gēng-zĭ Metal Rat Yang 37/60 |
||
</pre> |
</pre> |
||
=={{header|Yabasic}}== |
=={{header|Yabasic}}== |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="yabasic"> |
||
dim Animals$(12) : for a = 0 to 11 : read Animals$(a) : next a |
dim Animals$(12) : for a = 0 to 11 : read Animals$(a) : next a |
||
dim Elements$(5) : for a = 0 to 4 : read Elements$(a): next a |
dim Elements$(5) : for a = 0 to 4 : read Elements$(a): next a |
||
Line 4,516: | Line 4,454: | ||
2017 is the year of the Fire Rooster (Yin). |
2017 is the year of the Fire Rooster (Yin). |
||
</pre> |
</pre> |
||
=={{header|zkl}}== |
=={{header|zkl}}== |
||
{{trans|Ruby}} |
{{trans|Ruby}} |
||
<syntaxhighlight lang=zkl>fcn ceToChineseZodiac(ce_year){ // --> list of strings |
<syntaxhighlight lang="zkl">fcn ceToChineseZodiac(ce_year){ // --> list of strings |
||
# encoding: utf-8 |
# encoding: utf-8 |
||
var [const] pinyin=SD( // create some static variables, SD is small fixed dictionary |
var [const] pinyin=SD( // create some static variables, SD is small fixed dictionary |
||
Line 4,552: | Line 4,488: | ||
stem_pinyin,branch_pinyin, element,animal,aspect) |
stem_pinyin,branch_pinyin, element,animal,aspect) |
||
}</syntaxhighlight> |
}</syntaxhighlight> |
||
<syntaxhighlight lang=zkl>foreach ce_year in (T(1935,1938,1968,1972,1976,Time.Clock.UTC[0])){ |
<syntaxhighlight lang="zkl">foreach ce_year in (T(1935,1938,1968,1972,1976,Time.Clock.UTC[0])){ |
||
println("%d: %s%s (%s-%s, %s %s; %s)" |
println("%d: %s%s (%s-%s, %s %s; %s)" |
||
.fmt(ce_year,ceToChineseZodiac(ce_year).xplode())); |
.fmt(ce_year,ceToChineseZodiac(ce_year).xplode())); |