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 |
IF []STRING ending = ( "are", "ēre", "ere", "ire" ); |
||
length |
INT length = s length( lv ); |
||
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 |
THEN |
||
print( ( """", lv, """ is |
print( ( """", lv, """ is not long enough to conjugate", newline ) ) |
||
ELIF |
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" ) |
||
, ( "eo", "es", "et", "emus", "etis", "ent" ) |
|||
, ( "o", "is", "it", "imus", "itis", "unt" ) |
|||
, ( "io", "is", "it", "imus", "itis", "iunt" ) |
|||
⚫ | |||
); |
|||
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 |
print( ( "Present Indicative conjugation:", newline ) ); |
||
print conjugations( " |
print conjugations( "amare" ); |
||
print conjugations( " |
print conjugations( "monēre" ); |
||
print conjugations( " |
print conjugations( "tegere" ); |
||
print conjugations( "venire" ); |
|||
⚫ | |||
print conjugations( "qwerty" ); |
|||
print conjugations( "are" ) |
|||
END |
|||
⚫ | |||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Present Indicative conjugation: |
|||
Conjugations of "amare": |
Conjugations of "amare": |
||
amao |
|||
amo |
|||
amas |
|||
amat |
|||
amamus |
|||
amatis |
|||
amant |
|||
⚫ | |||
Conjugations of " |
Conjugations of "monēre": |
||
moneo |
|||
mones |
|||
monet |
|||
monemus |
|||
monetis |
|||
monent |
|||
Conjugations of "tegere": |
|||
⚫ | |||
tego |
|||
tegis |
|||
tegit |
|||
tegimus |
|||
tegitis |
|||
tegunt |
|||
Conjugations of "venire": |
|||
venio |
|||
venis |
|||
venit |
|||
venimus |
|||
venitis |
|||
veniunt |
|||
⚫ | |||
⚫ | |||
</pre> |
</pre> |
||