Abbreviations, automatic: Difference between revisions
→{{header|Perl 6}}: Refactor into a reusable subroutine rather than hard coding list. Add a line counter. Adjust output displayed to show infinite abbreviation
(→{{header|Kotlin}}: Changed code so that lines are now printed as soon as they're processed) |
Thundergnat (talk | contribs) (→{{header|Perl 6}}: Refactor into a reusable subroutine rather than hard coding list. Add a line counter. Adjust output displayed to show infinite abbreviation) |
||
Line 283:
=={{header|Perl 6}}==
{{works with|Rakudo|2017.08}}
Saving the "Days of Week, Also Known As" table to a local file DoWAKA.txt. Note: lines that have duplicate day names will get ∞ as the minimum number of characters, as there in no amount of characters that can be entered to distinguish the days uniquely. It is somewhat unclear as to what is meant by "return a null string". I have chosen to return Nil.
<lang perl6>sub
return Nil unless my @days = $string.words;
my $max = @days».chars.max;
for 0 .. $max {
}
}
# Testing
say ++$, ') ', .&auto-abbreviate for './DoWAKA.txt'.IO.line</lang>
{{out|Sample abbreviated (heh) output}}
<pre>1) 2: Sunday Monday Tuesday Wednesday Thursday Friday Saturday
2) 2: Sondag Maandag Dinsdag Woensdag Donderdag Vrydag Saterdag
3) 4: E_djelë E_hënë E_martë E_mërkurë E_enjte E_premte E_shtunë
4) 2: Ehud Segno Maksegno Erob Hamus Arbe Kedame
5) 5: Al_Ahad Al_Ithinin Al_Tholatha'a Al_Arbia'a Al_Kamis Al_Gomia'a Al_Sabit
...
4: djadomingu djaluna djamars djarason djaweps djabièrnè djasabra▼
90) ∞: Bazar_gÜnÜ Bazar_ærtæsi Çærs,ænbæ_axs,amò Çærs,ænbæ_gÜnÜ CÜmæ_axs,amò CÜmæ_gÜnÜ CÜmæ_gÜnÜ
2: Killachau Atichau Quoyllurchau Illapachau Chaskachau Kuychichau Intichau▼
91) 2: Sun Moon Mars Mercury Jove Venus Saturn
92) 2: zondag maandag dinsdag woensdag donderdag vrijdag zaterdag
93) 2: KoseEraa GyoOraa BenEraa Kuoraa YOwaaraa FeEraa Memenaa
94) 5: Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Sonnabend
95) 1: Domingo Luns Terza_feira Corta_feira Xoves Venres Sábado
96) 7: Dies_Solis Dies_Lunae Dies_Martis Dies_Mercurii Dies_Iovis Dies_Veneris Dies_Sabbatum
97) 12: xing-_qi-_tiàn xing-_qi-_yi-. xing-_qi-_èr xing-_qi-_san-. xing-_qi-_sì xing-_qi-_wuv. xing-_qi-_liù
▲98) 4: djadomingu djaluna djamars djarason djaweps djabièrnè djasabra
▲99) 2: Killachau Atichau Quoyllurchau Illapachau Chaskachau Kuychichau Intichau</pre>
=={{header|REXX}}==
|