Conjugate a Latin verb: Difference between revisions

From Rosetta Code
Content added Content deleted
m (→‎{{header|REXX}}: added a stub.)
m (→‎{{header|REXX}}: added the computer programming language REXX.)
Line 15: Line 15:
<br><br>
<br><br>
=={{header|REXX}}==
=={{header|REXX}}==
Checks were also made to ensure the Latin verb has only Latin letters (upper and/or lower case).
<lang rexx>/*REXX pgm conjugates (to the terminal) a Latin verb when given a first conjugation verb*/
parse arg verbs
if verbs='' | verbs="," then verbs= 'amare dare'
suffix= 'o as at amus atis ant' /*a list of six Latin verb suffixes. */
#= words(verbs) /*obtain the # of Latin verbs specified*/

do j=1 for #; say /*process each " " " */
$= word(verbs, j); $$= $; upper $$ /*obtain one of the " " " */
if \datatype($, 'M') then call ser "the following isn't a Latin verb: " $
L= length($) /*obtain the length of a Latin verb. */
if L<4 then call ser 'length of Latin verb is too short: ' $
if right($$, 3)\=='ARE' then call ser "the following isn't a Latin verb: " $
stem= left($, length($) - 3) /*obtain the stem of the Latin verb. */
say center(' present indicative tense of "'$'"', 50, "─")

do k=1 for words(suffix) /*display each of the verb suffixes. */
say left('',21) stem || word(suffix, k) /*display a Latin verb stem with auffix*/
end /*k*/
say
end /*j*/
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
ser: say; say '***error*** ' arg(1); say; exit 13</lang>
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
─────── present indicative tense of "amare"───────
amo
amas
amat
amamus
amatis
amant


─────── present indicative tense of "dare"────────
do
das
dat
damus
datis
dant
</pre>


=={{header|Wren}}==
=={{header|Wren}}==

Revision as of 18:55, 16 September 2021

Task
Conjugate a Latin verb
You are encouraged to solve this task according to the task description, using any language you may know.

Basic Data Operation
This is a basic data operation. It represents a fundamental action on a basic data type.

You may see other such operations in the Basic Data Operations category, or:

Integer Operations
Arithmetic | Comparison

Boolean Operations
Bitwise | Logical

String Operations
Concatenation | Interpolation | Comparison | Matching

Memory Operations
Pointers & references | Addresses

Task
Given the input: "amare", output the following, each on its own line:
amo
amas
amat
amamus
amatis
amant



REXX

Checks were also made to ensure the Latin verb has only Latin letters (upper and/or lower case). <lang rexx>/*REXX pgm conjugates (to the terminal) a Latin verb when given a first conjugation verb*/ parse arg verbs if verbs= | verbs="," then verbs= 'amare dare' suffix= 'o as at amus atis ant' /*a list of six Latin verb suffixes. */

  1. = words(verbs) /*obtain the # of Latin verbs specified*/
     do j=1  for #;                  say        /*process each      "     "       "    */
     $= word(verbs, j);  $$= $;      upper $$   /*obtain one of the "     "       "    */
     if \datatype($, 'M')  then call ser "the following isn't a Latin verb: "      $
     L= length($)                               /*obtain the length of a Latin verb.   */
     if L<4  then call ser 'length of Latin verb is too short: '     $
     if right($$, 3)\=='ARE'  then call ser "the following isn't a Latin verb: "   $
     stem= left($, length($) - 3)               /*obtain the stem of the Latin verb.   */
     say center(' present indicative tense of "'$'"', 50, "─")
        do k=1  for words(suffix)               /*display each of the verb suffixes.   */
        say left(,21) stem || word(suffix, k) /*display a Latin verb stem with auffix*/
        end   /*k*/
     say
     end      /*j*/

exit 0 /*stick a fork in it, we're all done. */ /*──────────────────────────────────────────────────────────────────────────────────────*/ ser: say; say '***error*** ' arg(1); say; exit 13</lang>

output   when using the default inputs:
─────── present indicative tense of "amare"───────
                      amo
                      amas
                      amat
                      amamus
                      amatis
                      amant


─────── present indicative tense of "dare"────────
                      do
                      das
                      dat
                      damus
                      datis
                      dant

Wren

<lang ecmascript>var conjugate = Fn.new { |infinitive|

   if (!infinitive.endsWith("are")) Fiber.abort("Not a first conjugation verb.")
   var stem = infinitive[0..-4]
   System.print("Present indicative tense of '%(infinitive)':")
   for (ending in ["o", "as", "at", "amus", "atis", "ant"]) {
       System.print("  " + stem + ending)
   }
   System.print()

}

for (infinitive in ["amare", "dare"]) conjugate.call(infinitive)</lang>

Output:
Present indicative tense of 'amare':
  amo
  amas
  amat
  amamus
  amatis
  amant

Present indicative tense of 'dare':
  do
  das
  dat
  damus
  datis
  dant