Conjugate a Latin verb: Difference between revisions

Content added Content deleted
m (dare is not completely regular)
(→‎{{header|ALGOL 68}}: Changed to revised task reuirements)
Line 29: Line 29:
=={{header|ALGOL 68}}==
=={{header|ALGOL 68}}==
<lang algol68>BEGIN # print some Latin verb conjugations #
<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 #
# prints the cojugations of lv or an error message if we don't know how to conjugate lv #
PROC print conjugations = ( STRING lv )VOID:
PROC print conjugations = ( STRING lv )VOID:
IF INT length = ( UPB lv + 1 ) - LWB lv;
IF []STRING ending = ( "are", "ēre", "ere", "ire" );
length < 4
INT length = s length( lv );
INT conjugation := 0;
INT ending length := 0;
BOOL long enough := FALSE;
FOR i FROM LWB ending TO UPB ending WHILE conjugation = 0 DO
ending length := s length( ending[ i ] );
IF ending length < length
THEN
# the word is long enough for at least one ending #
long enough := TRUE;
IF lv[ ( UPB lv + 1 ) - ending length : ] = ending[ i ]
THEN
conjugation := i
FI
FI
OD;
NOT long enough
THEN
THEN
print( ( """", lv, """ is too short to conjugate", newline ) )
print( ( """", lv, """ is not long enough to conjugate", newline ) )
ELIF lv[ UPB lv - 2 : ] /= "are"
ELIF conjugation = 0
THEN
THEN
print( ( "Don't know how to conjugate """, lv, """", newline ) )
print( ( "Don't know how to conjugate """, lv, """", newline ) )
ELSE
ELSE
[]STRING suffix = ( "o", "as", "at", "amus", "atis", "ant" );
[,]STRING suffix = ( ( "o", "as", "at", "amus", "atis", "ant" )
STRING prefix = lv[ : UPB lv - 2 ];
, ( "eo", "es", "et", "emus", "etis", "ent" )
print( ( "Conjugations of """, lv, """:", newline ) );
, ( "o", "is", "it", "imus", "itis", "unt" )
, ( "io", "is", "it", "imus", "itis", "iunt" )
FOR i FROM LWB suffix TO UPB suffix DO
print( ( " ", prefix, suffix[ i ], newline ) )
);
STRING prefix = lv[ : UPB lv - ending length ];
print( ( " Conjugations of """, lv, """:", newline ) );
FOR i FROM 2 LWB suffix TO 2 UPB suffix DO
print( ( " ", prefix, suffix[ conjugation, i ], newline ) )
OD
OD
FI # print confugations # ;
FI # print confugations # ;
print conjugations( "amare" );
print( ( "Present Indicative conjugation:", newline ) );
print conjugations( "veni" );
print conjugations( "amare" );
print conjugations( "dare" );
print conjugations( "monēre" );
print conjugations( "are" )
print conjugations( "tegere" );
print conjugations( "venire" );
END</lang>
print conjugations( "qwerty" );
print conjugations( "are" )
END
</lang>
{{out}}
{{out}}
<pre>
<pre>
Present Indicative conjugation:
Conjugations of "amare":
Conjugations of "amare":
amao
amaas
amo
amaat
amas
amaamus
amat
amaatis
amamus
amaant
amatis
amant
Don't know how to conjugate "veni"
Conjugations of "dare":
Conjugations of "monēre":
dao
moneo
daas
mones
daat
monet
daamus
monemus
daatis
monetis
daant
monent
Conjugations of "tegere":
"are" is too short to conjugate
tego
tegis
tegit
tegimus
tegitis
tegunt
Conjugations of "venire":
venio
venis
venit
venimus
venitis
veniunt
Don't know how to conjugate "qwerty"
"are" is not long enough to conjugate
</pre>
</pre>