Conjugate a Latin verb: Difference between revisions

m
syntax highlighting fixup automation
(Added Arturo implementation)
m (syntax highlighting fixup automation)
Line 28:
 
=={{header|ALGOL 68}}==
<langsyntaxhighlight lang="algol68">BEGIN # print some Latin verb conjugations #
PROC s length = ( STRING s )INT: ( UPB s + 1 ) - LWB s; # calculates the length of s #
# prints the cojugations of lv or an error message if we don't know how to conjugate lv #
Line 75:
print conjugations( "are" )
END
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 113:
=={{header|Arturo}}==
{{trans|Nim}}
<langsyntaxhighlight lang="rebol">endings: #[
{are}: ["o" "as" "at" "amus" "atis" "ant"]
{ēre}: ["eo" "es" "et" "emus" "etis" "ent"]
Line 135:
]
print ""
]</langsyntaxhighlight>
 
{{out}}
Line 180:
 
=={{header|F_Sharp|F#}}==
<langsyntaxhighlight lang="fsharp">
// Conjugate a Latin Verb. Nigel Galloway: September 17th., 2021
let myLatin (n:string)=printfn "Rogatus sum iungere verbum %s" n
Line 188:
myLatin "amare"
myLatin "creo"
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 204:
=={{header|Factor}}==
{{works with|Factor|0.99 2021-06-02}}
<langsyntaxhighlight lang="factor">USING: formatting io kernel math qw sequences ;
 
CONSTANT: pronouns {
Line 246:
 
"amāre" "love" conjugate. nl
"dāre" "give" conjugate.</langsyntaxhighlight>
{{out}}
<pre>
Line 268:
=={{header|FreeBASIC}}==
{{trans|Wren}}
<langsyntaxhighlight lang="freebasic">Sub conjugate(infinitive As String)
Dim As String ending(1 To 6) => {"o", "as", "at", "amus", "atis", "ant"}
Line 288:
conjugate("qwerty")
conjugate("are")
Sleep</langsyntaxhighlight>
{{out}}
<pre>Praesens indicativi temporis of 'amare':
Line 313:
{{trans|Wren}}
The 'extended' version.
<langsyntaxhighlight lang="go">package main
 
import (
Line 363:
conjugate(pair[0], pair[1])
}
}</langsyntaxhighlight>
 
{{out}}
Line 406:
 
====Part 1====
<langsyntaxhighlight lang="jq">def conjugate:
if endswith("are") | not
then "\(.) is not a first conjugation verb." | error
Line 419:
 
("amare", "dare")
| conjugate</langsyntaxhighlight>
{{out}}
As for [[#Wren]].
 
====Part 2====
<syntaxhighlight lang="text">def rpad($len): tostring | ($len - length) as $l | . + (" " * $l)[:$l];
 
def endings: [
Line 456:
 
pairs[]
| conjugate(.[0]; .[1])</langsyntaxhighlight>
{{out}}
As for [[#Wren]].
 
=={{header|Julia}}==
<langsyntaxhighlight lang="julia">const conjugators = ["ō", "ās", "at", "āmus", "ātis", "ant"]
conjugate(w, gregex = r"[aā]re$") = (r = replace(w, gregex => ""); [r * s for s in conjugators])
 
Line 474:
 
testregularconjugation(["amāre", "dare"])
</langsyntaxhighlight>{{out}}
<pre>
Present active indicative conjugation of amāre:
Line 496:
{{trans|Go}}
{{Works with|Nim|1.6.0}}
<langsyntaxhighlight Nimlang="nim">import std/[strformat, unicode]
 
const
Line 524:
 
for (infinitive, english) in {"amare": "love", "vidēre": "see", "ducere": "lead", "audire": "hear"}:
conjugate(infinitive, english)</langsyntaxhighlight>
 
{{out}}
Line 561:
=={{header|Perl}}==
{{trans|Raku}}
<langsyntaxhighlight lang="perl">use strict;
use warnings;
use feature 'say';
Line 576:
my($verb) = $infinitive =~ /^ (\w+) [aā] re $/x;
say $verb ? conjugate $verb : "Sorry, don't know how to conjugate $infinitive"
</syntaxhighlight>
</lang>
{{out}}
<pre>Present active indicative conjugation of infinitive amāre.
Line 596:
=={{header|Phix}}==
TL; DR: Did just one term of Latin, right before posting this realised 'dāre' should probably be 'dare', left as an exercise...
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">constant</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">ending</span><span style="color: #0000FF;">,</span><span style="color: #000000;">endings</span><span style="color: #0000FF;">}</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">columnize</span><span style="color: #0000FF;">({{</span><span style="color: #008000;">"āre"</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">split</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"ō ās at āmus ātis ant"</span><span style="color: #0000FF;">)},</span>
Line 623:
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #008000;">""</span><span style="color: #0000FF;">,{</span><span style="color: #008000;">"unicode_align"</span><span style="color: #0000FF;">,</span><span style="color: #004600;">true</span><span style="color: #0000FF;">})</span>
<span style="color: #7060A8;">papply</span><span style="color: #0000FF;">({{</span><span style="color: #008000;">"amāre"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"love"</span><span style="color: #0000FF;">},{</span><span style="color: #008000;">"dāre"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"give"</span><span style="color: #0000FF;">},{</span><span style="color: #008000;">"vidēre"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"see"</span><span style="color: #0000FF;">},{</span><span style="color: #008000;">"dūcere"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"lead"</span><span style="color: #0000FF;">},{</span><span style="color: #008000;">"audīre"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"hear"</span><span style="color: #0000FF;">}},</span><span style="color: #000000;">conjugate</span><span style="color: #0000FF;">)</span>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 669:
=={{header|Python}}==
{{trans|Wren}}
<langsyntaxhighlight lang="python">#!/usr/bin/python
 
Line 690:
if __name__ == '__main__':
for infinitive in ("amare", "dare", "qwerty", "are"):
conjugate(infinitive)</langsyntaxhighlight>
 
 
Line 696:
{{trans|Julia}}
 
<syntaxhighlight lang="raku" perl6line>for <amāre dare> -> $infinitive {
say "\nPresent active indicative conjugation of infinitive $infinitive.";
my $verb = ($infinitive ~~ /^ (\w+) ['a'|'ā'] 're' $/)[0];
Line 702:
}
 
sub conjugate ($verb) { ($verb X~ <ō ās at āmus ātis ant>).join: "\n" }</langsyntaxhighlight>
{{out}}
<pre>Present active indicative conjugation of infinitive amāre.
Line 722:
=={{header|REXX}}==
Checks were also made to ensure the Latin verb has only Latin letters (upper and/or lower case).
<langsyntaxhighlight lang="rexx">/*REXX pgm conjugates (to the terminal) a Latin verb when given a first conjugation verb*/
parse arg verbs
if verbs='' | verbs="," then verbs= 'amare dare'
Line 744:
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
ser: say; say '***error*** ' arg(1); say; exit 13</langsyntaxhighlight>
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
Line 766:
 
=={{header|Wren}}==
<langsyntaxhighlight lang="ecmascript">var conjugate = Fn.new { |infinitive|
if (!infinitive.endsWith("are")) Fiber.abort("Not a first conjugation verb.")
var stem = infinitive[0...-3]
Line 777:
}
 
for (infinitive in ["amare", "dare"]) conjugate.call(infinitive)</langsyntaxhighlight>
 
{{out}}
Line 800:
{{libheader|Wren-fmt}}
The following extended version can deal with regular verbs of all four conjugations. To distinguish 2nd and 3rd conjugations, a bar is placed above the penultimate 'e' in a second conjugation infinitive but accents are otherwise ignored. English meanings have also been added.
<langsyntaxhighlight lang="ecmascript">import "/fmt" for Fmt
 
var endings = [
Line 832:
 
var pairs = [["amare", "love"], ["vidēre", "see"], ["ducere", "lead"], ["audire", "hear"]]
for (pair in pairs) conjugate.call(pair[0], pair[1])</langsyntaxhighlight>
 
{{out}}
10,333

edits