Description
1. Write a Ruby function to reverse a string. Use idiomatic Ruby. [10]
2. Given an array of integers, write a Ruby function to find the longest
Arithmetic progression in the list. [10]
3. Implement a method foldl for Ruby’s arrays.
This function will take a block as an argument. Kindly recall that a
block in Ruby is essentially an anonymous λ function.
The “list” argument in Haskell is the receiver object in Ruby.
So foldl f id lst in Haskell will be equivalent to array.foldl id
<block>. [15]
4. See the file md.rb for a simple parser for a modification of the mark-
down format. The file sample.md illustrates the format.
The class BasicOutputter takes a modified markdown file and speci-
fies the functions to be implemented to convert the file into an output
format. A very basic, incomplete implementation to output HTML is
given as part of the code.
Implement a class to output LaTeX format for a given modified mark-
down file. [25]
5. You are given the code for the dungeon game showed in class. To run
this code, you have to install gosu : gem install gosu. Compile and
run the given code.
Note that in the given hierarchy, the Princess can wield a weapon.
Improve the design of the software by creating a superclass for the
1Player class which abstracts out only the common characteristics of
the Plumber, the Dragon and the Princess. Ensure that your code
compiles and runs. [20]
(Tile Set credits: The tile set is modified from a royalty-free tileset
with Creative Commons 0 level license, permitting unrestricted use. I
wish to thank 0x72 at https://0x72.itch.io/dungeontileset-ii.)
2