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 length = s length(
INT conjugation := 0;
INT ending length := 0;
BOOL long enough := FALSE;
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
ELIF
THEN
print( ( "Don't know how to conjugate """, lv, """", newline ) )
ELSE
[,]STRING suffix = ( ( "o", "as", "at", "amus", "atis", "ant" )
, ( "io", "is", "it", "imus", "itis", "iunt" )
▲ FOR i FROM LWB suffix TO UPB suffix DO
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(
print conjugations( "
print conjugations( "
print conjugations( "
print conjugations( "venire" );
END</lang>▼
print conjugations( "qwerty" );
print conjugations( "are" )
END
{{out}}
<pre>
Present Indicative conjugation:
Conjugations of "amare":
amant
Don't know how to conjugate "veni"▼
Conjugations of "
Conjugations of "tegere":
"are" is too short to conjugate▼
tego
tegis
tegit
tegimus
tegitis
tegunt
Conjugations of "venire":
venio
venis
venit
venimus
venitis
veniunt
</pre>
|