]]> ]]>

Факториал в Shakespeare

Пример для версий Lingua::Shakespeare 1.00

Используется итеративное определение факториала. В первой сцене инициализируются переменная факториала (счетчик цикла по умолчанию равен 0), а также ряд переменных-символов. Вторая сцена — цикл, в котором выводятся текущее число и его факториал, а затем проверяется, равно ли текущее число 17 — если да, цикл прекращается.

use Lingua::Shakespeare;

Elizabethan Factorial.

Ferdinand, for factorial.
Isabella, for loop index.
Emilia, for exclamation mark.
Sebastian, for space.
Egeus, for equality sign.
Lucio, for newline.

Act I: Factorial calculations.

Scene I: Initialization.

[Enter Isabella and Sebastian]

Isabella:
  You are as fat as the product of a big black furry old cat and a white cow!

[Exit Sebastian]
[Enter Emilia]

Isabella:
  You are as distasteful as the sum of Sebastian and a chihuahua!

[Exit Emilia]
[Enter Egeus]

Isabella:
  You are as good as the difference between the sum of Sebastian and Emilia and a bold brave hero!

[Exit Egeus]
[Enter Lucio]

Isabella:
  You are as cute as the sum of a peaceful warm delicious summer's day and a cute squirrel!

[Exit Lucio]
[Enter Ferdinand]

Isabella:
  You brother!

Scene II: Loop.

Ferdinand:
  Open your heart!

[Exit Ferdinand]
[Enter Emilia]

Isabella:
  Speak your mind!

[Exit Emilia]
[Enter Sebastian]

Isabella:
  Speak your mind!

[Exit Sebastian]
[Enter Egeus]

Isabella:
  Speak your mind!

[Exit Egeus]
[Enter Sebastian]

Isabella:
  Speak your mind!

[Exit Sebastian]
[Enter Ferdinand]

Isabella:
  Open your heart!

[Exit Ferdinand]
[Enter Lucio]

Isabella:
  Speak your mind!

[Exit Lucio]
[Enter Ferdinand]

Ferdinand:
  You are as good as the sum of yourself and a rose.

Isabella:
  You are as gentle as the product of myself and yourself.
  Am I not as beautiful as the sum of your sweet charming lovely noble sister and a flower?

Ferdinand:
  If so, let us return to scene II.

[Exeunt]

Комментарии

]]>

blog comments powered by Disqus

]]>

Работа программистам