Conjugate a Latin verb: Difference between revisions

Add Factor
m (added related tasks.)
(Add Factor)
Line 64:
daant
"are" is too short to conjugate
</pre>
 
=={{header|Factor}}==
{{works with|Factor|0.99 2021-06-02}}
<lang factor>USING: formatting io kernel math qw sequences ;
 
CONSTANT: pronouns {
"I"
"you (singular)"
"he, she, it"
"we"
"you (plural)"
"they"
}
 
CONSTANT: endings qw{ ō ās at āmus ātis ant }
 
: first-conjugation? ( str -- ? )
qw{ are āre } [ tail? ] with any? ;
 
: check-first-conjugation ( str -- )
first-conjugation?
[ "Input must end with 'are' or 'āre'." throw ] unless ;
 
: check-length ( str -- )
length 3 >
[ "Input too short to conjugate." throw ] unless ;
 
: check-input ( str -- )
[ check-first-conjugation ] [ check-length ] bi ;
 
: conjugate ( str -- seq )
dup check-input 3 head* endings [ append ] with map ;
 
: conjugate. ( str -- )
dup "Present active indicative conjugations of %s:\n" printf
pronouns swap conjugate [ " %-16s%s\n" printf ] 2each ;
 
"amāre" conjugate. nl
"dāre" conjugate.</lang>
{{out}}
<pre>
Present active indicative conjugations of amāre:
I amō
you (singular) amās
he, she, it amat
we amāmus
you (plural) amātis
they amant
 
Present active indicative conjugations of dāre:
I dō
you (singular) dās
he, she, it dat
we dāmus
you (plural) dātis
they dant
</pre>
 
1,808

edits