Conjugate a Latin verb: Difference between revisions

→‎{{header|ALGOL 68}}: Changed to revised task reuirements
m (dare is not completely regular)
(→‎{{header|ALGOL 68}}: Changed to revised task reuirements)
Line 29:
=={{header|ALGOL 68}}==
<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 #
PROC print conjugations = ( STRING lv )VOID:
IF INT[]STRING lengthending = ( UPB lv= +( 1"are", )"ēre", -"ere", LWB"ire" lv);
INT length = s length( <lv 4);
INT conjugation := 0;
INT ending length := 0;
BOOL long enough := FALSE;
FOR i FROM LWB suffixending TO UPB suffixending 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
print( ( """", lv, """ is toonot long shortenough to conjugate", newline ) )
ELIF lv[conjugation UPB lv - 2 : ] /= "are"0
THEN
print( ( "Don't know how to conjugate """, lv, """", newline ) )
ELSE
[,]STRING suffix = ( ( "o", "as", "at", "amus", "atis", "ant" );
STRING prefix = lv[ : UPB lv - 2 ]; , ( "eo", "es", "et", "emus", "etis", "ent" )
print( ( "Conjugations of , ( "o", "is", lv"it", "imus", ":itis", newline )"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
FI # print confugations # ;
print( conjugations( "amarePresent Indicative conjugation:", newline ) );
print conjugations( "veniamare" );
print conjugations( "daremonēre" );
print conjugations( "aretegere" );
print conjugations( "venire" );
END</lang>
print conjugations( "qwerty" );
print conjugations( "are" )
END
END</lang>
{{out}}
<pre>
Present Indicative conjugation:
Conjugations of "amare":
amao
amaas amo
amaat amas
amaamus amat
amaatis amamus
amaant amatis
amant
Don't know how to conjugate "veni"
Conjugations of "daremonē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 "veniqwerty"
"are" is toonot shortlong enough to conjugate
</pre>
 
3,030

edits