Thursday, April 3, 2014

Prettification of solution to 12 in Shakespeare

So, as those who have been reading this blog may know, I am the creator and maintainer of an open-source Shakespeare compiler at https://github.com/drsam94/Spl/. I used Shakespeare for problem 12, but I wasn't entirely happy with it as it used an ugly feature of Shakespeare, which is that you had to write "Let us return to Scene I" to return to scene 1, etc. That is very unshakesperian! So, I recently added a language feature that allows you to go to acts/scenes by name, as exemplified by the following prettified version of my solution to problem 12 (it has about 3 gotos, but they look so much nicer now). "If so, let us proceed to the Final Judgment. If not, let us return to Real factoring."
The Tale of the 12th Euler.

Juliet, a young woman with a love for triangles.
Ophelia, another young woman who loves factors.
Octavia, a young woman who holds a big number.
Macbeth, a temporary young man who likes roots.
Romeo, a man who likes counting (and Juliet).
Julia, a young woman who also counts.

    Act I: Some smalltalk (not the Squeak kind)

    Scene I: Octavia's Initialization

[Enter Juliet and Octavia]

Juliet:
    You cute beautiful amazing sweet sunny trustworthy gentle 
    golden good girl! You are as pretty as the difference between 
    thyself and the sum of a brave charming bold noble warrior and 
    the evil dirty devil!

Octavia:
 You are a pretty girl too, thanks much for the accolades.

[Exeunt]
[Enter Macbeth and Romeo]
  
    Act II: A non-trifling time

    Scene I: Getting to work

Macbeth:
    You are as cunning as the sum of thyself and a hero.

[Exit Macbeth]

[Enter Juliet]
Romeo:
    You are as lovely as the quotient of the product of myself 
    and the sum of myself and Heaven and a good King!

[Exit Juliet]

[Enter Macbeth]
Romeo:
    You are as prompt as the square root of Juliet!
[Exit Macbeth]

[Enter Ophelia]
  
    Scene II: Getting ready to factor

Romeo: 
 You are nothing at all.

Ophelia: 
 Is the square of Macbeth as noble as Juliet?

Romeo: 
 If so, you are as beautiful as a flower.

[Exit Romeo]
[Enter Julia]

Ophelia: 
 You are an angel.


    Scene III: Real factoring

Ophelia: 
 Is the remainder of the quotient between Juliet and thee better than nothing?
         
Julia:
 If not, you are as pretty as the sum of thyself and a golden flower.

Ophelia:
 You are as cute as the sum of yourself and a plum. 
 Art thou more pretty than Macbeth?

Julia:
 If so, let us proceed to the Final Judgment. If not, let 
 us return to Real factoring.

    Scene IV: The Final Judgment.

[Exeunt]
[Enter Romeo and Ophelia]

Romeo:
 Are you more pretty than Octavia?

Ophelia:
 If so, let us proceed to printing the answer.

[Exit Ophelia]
[Enter Macbeth]

Macbeth:
 Let us return to getting to work.

    Scene V: Printing the Answer.

[Exeunt]
[Enter Juliet and Ophelia]

Ophelia: 
 Open Your Heart!

Juliet: 
 You are as beautiful as the product of a good man and the sum 
 of the lord and a cute golden girl. Speak Your Mind!

[Exeunt]

No comments:

Post a Comment