Transliterate English text using the Greek alphabet: Difference between revisions
Content added Content deleted
m (→{{header|J}}) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 100: | Line 100: | ||
{{trans|Julia}} |
{{trans|Julia}} |
||
Implementation: |
Implementation: |
||
< |
<syntaxhighlight lang="j">endings=: {{ |
||
W=. (#~ tolower=toupper) (32}.127{.a.)-.":1234567890x |
W=. (#~ tolower=toupper) (32}.127{.a.)-.":1234567890x |
||
,(x,"1 0 W);&(7&u:)"1 y,"1 0 W |
,(x,"1 0 W);&(7&u:)"1 y,"1 0 W |
||
Line 114: | Line 114: | ||
'D';'Δ'; 'F';'Φ'; 'G';'Γ'; 'J';'I'; 'L';'Λ'; 'P';'Π'; 'Q';'Κ'; |
'D';'Δ'; 'F';'Φ'; 'G';'Γ'; 'J';'I'; 'L';'Λ'; 'P';'Π'; 'Q';'Κ'; |
||
'R';'Ρ'; 'S';'Σ'; 'Y';'U'; 'W';'Ω'; 'X';'Ξ' |
'R';'Ρ'; 'S';'Σ'; 'Y';'U'; 'W';'Ω'; 'X';'Ξ' |
||
}} -.LF)^:_</ |
}} -.LF)^:_</syntaxhighlight> |
||
Examples: |
Examples: |
||
< |
<syntaxhighlight lang="j">txt1=:'The quick brown fox jumped over the lazy dog.' |
||
txt2=:{{)n |
txt2=:{{)n |
||
I was looking at some rhododendrons in my back garden, |
I was looking at some rhododendrons in my back garden, |
||
Line 140: | Line 140: | ||
trans txt3 |
trans txt3 |
||
σφινξ οφ βλακ κυαρτζ, ιυδγε μυ βοω.</ |
σφινξ οφ βλακ κυαρτζ, ιυδγε μυ βοω.</syntaxhighlight> |
||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
< |
<syntaxhighlight lang="ruby">const texts = [ |
||
"""The quick brown fox jumped over the lazy dog.""", |
"""The quick brown fox jumped over the lazy dog.""", |
||
"""I was looking at some rhododendrons in my back garden, |
"""I was looking at some rhododendrons in my back garden, |
||
Line 170: | Line 170: | ||
println("$txt\n", "="^65) |
println("$txt\n", "="^65) |
||
end |
end |
||
</ |
</syntaxhighlight>{{out}} |
||
<pre> |
<pre> |
||
The quick brown fox jumped over the lazy dog. |
The quick brown fox jumped over the lazy dog. |
||
Line 197: | Line 197: | ||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
< |
<syntaxhighlight lang="perl">use v5.36; |
||
use experimental 'for_list'; |
use experimental 'for_list'; |
||
use utf8; |
use utf8; |
||
Line 212: | Line 212: | ||
'The quick brown fox jumped over the lazy dog.', |
'The quick brown fox jumped over the lazy dog.', |
||
'I was looking at some rhododendrons in my back garden, dressed in my khaki shorts, when the telephone rang.', |
'I was looking at some rhododendrons in my back garden, dressed in my khaki shorts, when the telephone rang.', |
||
'As I answered it, I cheerfully glimpsed that the July sun caused a fragment of black pine wax to ooze on the velvet quilt laying in my patio.';</ |
'As I answered it, I cheerfully glimpsed that the July sun caused a fragment of black pine wax to ooze on the velvet quilt laying in my patio.';</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>The quick brown fox jumped over the lazy dog. |
<pre>The quick brown fox jumped over the lazy dog. |
||
Line 227: | Line 227: | ||
Just for a laugh, figure out the rules directly from the task description. |
Just for a laugh, figure out the rules directly from the task description. |
||
You can run this online [http://phix.x10.mx/p2js/greek.htm here] (and it'll probably look better in a browser than on a Windows console). |
You can run this online [http://phix.x10.mx/p2js/greek.htm here] (and it'll probably look better in a browser than on a Windows console). |
||
<!--< |
<!--<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;">task</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">""" |
<span style="color: #008080;">constant</span> <span style="color: #000000;">task</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">""" |
||
Line 318: | Line 318: | ||
<span style="color: #000000;">g</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">join</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">extract</span><span style="color: #0000FF;">(</span><span style="color: #000000;">names</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">substitute_all</span><span style="color: #0000FF;">(</span><span style="color: #000000;">thedog</span><span style="color: #0000FF;">,</span><span style="color: #000000;">sub</span><span style="color: #0000FF;">,</span><span style="color: #000000;">rep</span><span style="color: #0000FF;">)),</span><span style="color: #008000;">""</span><span style="color: #0000FF;">)</span> |
<span style="color: #000000;">g</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">join</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">extract</span><span style="color: #0000FF;">(</span><span style="color: #000000;">names</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">substitute_all</span><span style="color: #0000FF;">(</span><span style="color: #000000;">thedog</span><span style="color: #0000FF;">,</span><span style="color: #000000;">sub</span><span style="color: #0000FF;">,</span><span style="color: #000000;">rep</span><span style="color: #0000FF;">)),</span><span style="color: #008000;">""</span><span style="color: #0000FF;">)</span> |
||
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%s\n=>\n%s\n\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">thedog</span><span style="color: #0000FF;">,</span><span style="color: #000000;">g</span><span style="color: #0000FF;">})</span> |
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%s\n=>\n%s\n\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">thedog</span><span style="color: #0000FF;">,</span><span style="color: #000000;">g</span><span style="color: #0000FF;">})</span> |
||
<!--</ |
<!--</syntaxhighlight>--> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 347: | Line 347: | ||
=={{header|Raku}}== |
=={{header|Raku}}== |
||
<lang |
<syntaxhighlight lang="raku" line>sub to-Greek (Str $string is copy) { |
||
my %pre = :Ph<F>, :ck<k>, :ee<h>, :J<I>, :rh<r>,:oo<w>, :ph<f>, :ch<χ>, |
my %pre = :Ph<F>, :ck<k>, :ee<h>, :J<I>, :rh<r>,:oo<w>, :ph<f>, :ch<χ>, |
||
:th<θ>, :ps<ψ>, :Ch<Χ>, :Th<Θ>, :Ps<Ψ>, :kh<χ>, 's ' => 'ς '; |
:th<θ>, :ps<ψ>, :Ch<Χ>, :Th<Θ>, :Ps<Ψ>, :kh<χ>, 's ' => 'ς '; |
||
Line 382: | Line 382: | ||
'<' ~ .uniname.subst( /.+<?after LETTER\s>/).lc ~ '>' |
'<' ~ .uniname.subst( /.+<?after LETTER\s>/).lc ~ '>' |
||
}).join |
}).join |
||
given 'sphinx of black quartz, judge my vow.';</ |
given 'sphinx of black quartz, judge my vow.';</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>English: |
<pre>English: |
||
Line 417: | Line 417: | ||
=={{header|Wren}}== |
=={{header|Wren}}== |
||
{{libheader|Wren-str}} |
{{libheader|Wren-str}} |
||
< |
<syntaxhighlight lang="ecmascript">import "./str" for Char, Greek |
||
var English2Greek = Fn.new { |text| |
var English2Greek = Fn.new { |text| |
||
Line 524: | Line 524: | ||
s = s + c |
s = s + c |
||
} |
} |
||
System.print(s)</ |
System.print(s)</syntaxhighlight> |
||
{{out}} |
{{out}} |