Conjugate a Latin verb: Difference between revisions

Added Go
(→‎{{header|Wren}}: Added English meanings to extended version.)
(Added Go)
Line 196:
dātis you all give
dant they give
</pre>
 
=={{header|Go}}==
{{trans|Wren}}
The 'extended' version.
<lang go>package main
 
import (
"fmt"
"log"
)
 
var endings = [][]string{
{"o", "as", "at", "amus", "atis", "ant"},
{"eo", "es", "et", "emus", "etis", "ent"},
{"o", "is", "it", "imus", "itis", "unt"},
{"io", "is", "it", "imus", "itis", "iunt"},
}
 
var infinEndings = []string{"are", "ēre", "ere", "ire"}
 
var pronouns = []string{"I", "you (singular)", "he, she or it", "we", "you (plural)", "they"}
 
var englishEndings = []string{"", "", "s", "", "", ""}
 
func conjugate(infinitive, english string) {
letters := []rune(infinitive)
le := len(letters)
if le < 4 {
log.Fatal("Infinitive is too short for a regular verb.")
}
infinEnding := string(letters[le-3:])
conj := -1
for i, s := range infinEndings {
if s == infinEnding {
conj = i
break
}
}
if conj == -1 {
log.Fatalf("Infinitive ending -%s not recognized.", infinEnding)
}
stem := string(letters[:le-3])
fmt.Printf("Present indicative tense, active voice, of '%s' to '%s':\n", infinitive, english)
for i, ending := range endings[conj] {
fmt.Printf(" %s%-4s %s %s%s\n", stem, ending, pronouns[i], english, englishEndings[i])
}
fmt.Println()
}
 
func main() {
pairs := [][2]string{{"amare", "love"}, {"vidēre", "see"}, {"ducere", "lead"}, {"audire", "hear"}}
for _, pair := range pairs {
conjugate(pair[0], pair[1])
}
}</lang>
 
{{out}}
<pre>
Present indicative tense, active voice, of 'amare' to 'love':
amo I love
amas you (singular) love
amat he, she or it loves
amamus we love
amatis you (plural) love
amant they love
 
Present indicative tense, active voice, of 'vidēre' to 'see':
video I see
vides you (singular) see
videt he, she or it sees
videmus we see
videtis you (plural) see
vident they see
 
Present indicative tense, active voice, of 'ducere' to 'lead':
duco I lead
ducis you (singular) lead
ducit he, she or it leads
ducimus we lead
ducitis you (plural) lead
ducunt they lead
 
Present indicative tense, active voice, of 'audire' to 'hear':
audio I hear
audis you (singular) hear
audit he, she or it hears
audimus we hear
auditis you (plural) hear
audiunt they hear
</pre>
 
9,485

edits